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.

TMS320F28021: Custom OTP SCI Boot Jumps to start normal start of FlashA (0x3F7FF6) but only runs if using debugger.

Part Number: TMS320F28021
Other Parts Discussed in Thread: TMS320F28035, CONTROLSUITE

I have a modified SCI bootloader that I want to move  from FlashA to OTP.  I switched from a TMS320F28035 where the loader used to run in FlashA with no problems to a TMS320F28021 and want to use the same loader only in OTP.   If the loader is loaded into FlashA on the 28021 it  works well.  If I download a new image It can overwrite itself and run the application with the standard jump to flash on a cpu reset (GPIO37 =1, GPIO34=1, TRST=0);  When I put the loader into OTP, it starts (I have an led turn on, from a fresh power cycle), verifies the application image (which is good),  jumps to FlashA(0x3F7FF6)  and just sits there (from what I can tell from using  the debugger).  If I download the image (bootloader) using the debugger into OTP and hit the play button, it works fine.  I've been floundering for a couple of days trying to figure out what the issue is (and I'm running out of bad board to test with), so any help is much appreciated. All the project files have been converted over to the 28021 from the 28035.  Thanks much, Ron.  

The only thing I wasn't sure about is the ExitBoot from the InitBoot.asm that I borrowed from the boot 28035 example (if it's compatible with the 28021), from they're both from the C2000 family?

The linker command file is below and I use InitBoot.asm (supplied by TI control Suite xx\controlSUITE\libs\utilities\boot_rom\2803x\2803x_boot_rom_v1) for the SCI bootloader to set the OTP Boot Values.

MEMORY
{
PAGE 0 :
	    SCIBOOTINIT : origin = 0x3D7800, length = 0x000050
	    SCIBOOT     : origin = 0x3D7850, length = 0x0002FE
	    VERSION     : origin = 0x3D7B50, length = 0x000004    //2 words  // Current Version of BootLoader and date
        BEGIN       : origin = 0x3D7B54, length = 0x000002     /* Used for "boot to Flash" bootloader mode. OTP */

        OTP_KEY     : origin = 0x3D7BFE, length = 0x000001 /* Boot From One Time Programming  */
        OTP_BMODE   : origin = 0x3D7BFF, length = 0x000001 /* Boot From One Time Programming */


PAGE 1 :
         EBSS      : origin = 0x0400, length = 0x002
         STACK     : origin = 0x0402, length = 0x200
}

SECTIONS
{
         .InitBoot    : load = SCIBOOTINIT,  PAGE = 0
         codestart           : > BEGIN       PAGE = 0
         .text        : load = SCIBOOT,      PAGE = 0
         .stack       : load = STACK,        PAGE = 1
         .ebss        : load = EBSS,         PAGE = 1
         .Version     : load = VERSION,      PAGE = 0
         OTP_BMODE    : > OTP_BMODE,         PAGE = 0 /*Add OTP Boot Mode*/
         OTP_KEY      : > OTP_KEY,           PAGE = 0 /*Add OTP Boot Key*/

}

InitBoot.asm

    .global _InitBoot
    .ref _SCI_Boot
;;    .sect ".Flash"   ; Flash API checks this for
;;   .word 0xFFFE     ; silicon compatability

    .sect "OTP_KEY"
    .word 0x55AA

    .sect "OTP_BMODE"
    .word 0x0006

    .sect ".Version"
    .word 0x0001     ; Boot ROM Version v.001
    .word 0x0414     ; Month/Year: (ex: 0x0414 = 4/20 = Aug 2020)
                     ; Use Hexidecimal for Month/Year


    .sect ".InitBoot"

;--------------------------------------------------------------------------------------------------------------------------------------------

Linker File for Application:

MEMORY
{
PAGE 0:    /* Program Memory */
           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */

   RAMM0       : origin = 0x000050, length = 0x0003B0     /* on-chip RAM block M0 */
   OTP         : origin = 0x3D7800, length = 0x000400     /* on-chip OTP */
   FLASHD      : origin = 0x3F0000, length = 0x004050     /* on-chip FLASH 3000*/
   FLASHC      : origin = 0x3F4050, length = 0x000FB0     /* on-chip FLASH 1000 */
   FLASHB      : origin = 0x3F5000, length = 0x001000     /* on-chip FLASH */
   FLASHA      : origin = 0x3F6000, length = 0x001F7C     /* on-chip FLASH - Note Last 4 bytes of Flash A is used for bootloader checks */
   CSM_RSVD    : origin = 0x3F7F80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */
   BEGIN       : origin = 0x3F7FF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */
   CSM_PWL_P0  : origin = 0x3F7FF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */

   IQTABLES    : origin = 0x3FE000, length = 0x000B50     /* IQ Math Tables in Boot ROM */
   IQTABLES2   : origin = 0x3FEB50, length = 0x00008C     /* IQ Math Tables in Boot ROM */
   IQTABLES3   : origin = 0x3FEBDC, length = 0x0000AA     /* IQ Math Tables in Boot ROM */

   ROM         : origin = 0x3FF27C, length = 0x000D44     /* Boot ROM */
   RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */
   VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */

PAGE 1 :   /* Data Memory */
           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */
           /* Registers remain on PAGE1                                                  */

   BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */
   RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */
   DRAML0      : origin = 0x008000, length = 0x000C00     /* on-chip RAM block L0 */
}

/* Allocate sections to memory blocks.
   Note:
         codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code
                   execution when booting to flash
         ramfuncs  user defined section to store functions that will be copied from Flash into RAM
*/

SECTIONS
{

   /* Allocate program areas: */
   .cinit              : > FLASHC      PAGE = 0
   .pinit              : > FLASHC,     PAGE = 0
   .text               : > FLASHD      PAGE = 0
   codestart           : > BEGIN       PAGE = 0
   ramfuncs            : LOAD = FLASHA,
                         RUN = RAMM0,

                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_SIZE(_RamfuncsLoadSize),
                         RUN_START(_RamfuncsRunStart),

                     /*  LOAD_START(_RamfuncsLoadStart),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart), */
                         PAGE = 0

   csmpasswds          : > CSM_PWL_P0  PAGE = 0
   csm_rsvd            : > CSM_RSVD    PAGE = 0

   /* Allocate uninitalized data sections: */
   .stack              : > RAMM1       PAGE = 1
   .ebss               : > DRAML0      PAGE = 1
   .cio                : > DRAML0       PAGE = 1 /* was PRAML0 PAGE 0 */
   .esysmem            : > RAMM1        PAGE = 1

   /* Initalized sections go in Flash */
   /* For SDFlash to program these, they must be allocated to page 0 */
   .econst             : > FLASHA      PAGE = 0
   .switch             : > FLASHB      PAGE = 0

   /* Allocate IQ math areas: */
   IQmath              : > FLASHB      PAGE = 0            /* Math Code */
   IQmathTables        : > IQTABLES,   PAGE = 0, TYPE = NOLOAD

 

   /* DSECT  */
   .reset              : > RESET,      PAGE = 0, TYPE = DSECT
   vectors             : > VECTORS     PAGE = 0, TYPE = DSECT

}

---------------------------------------------------------------------------------------------------------------------------------------------------------------

The Jump to Flash A from InitBoot.asm (control Suite C:\TI\controlSUITE\libs\utilities\boot_rom\2803x\2803x_boot_rom_v1)

EntryAddr= 0x3F7FF6

...

...

_ExitBoot:

;-----------------------------------------------
;   Insure that the stack is deallocated
;-----------------------------------------------

    MOV SP,#__stack

;-----------------------------------------------
; Clear the bottom of the stack.  This will endup
; in RPC when we are finished
;-----------------------------------------------

    MOV  *SP++,#0
    MOV  *SP++,#0

;-----------------------------------------------
; Load RPC with the entry point as determined
; by the boot mode.  This address will be returned
; in the ACC register.
;-----------------------------------------------

    PUSH ACC
    POP  RPC

;-----------------------------------------------
; Put registers back in their reset state.
;
; Clear all the XARn, ACC, XT, and P and DP
; registers
;
; NOTE: Leave the device in C28x operating mode
;       (OBJMODE = 1, AMODE = 0)
;-----------------------------------------------
    ZAPA
    MOVL  XT,ACC
    MOVZ  AR0,AL
    MOVZ  AR1,AL
    MOVZ  AR2,AL
    MOVZ  AR3,AL
    MOVZ  AR4,AL
    MOVZ  AR5,AL
    MOVZ  AR6,AL
    MOVZ  AR7,AL
    MOVW  DP, #0

;------------------------------------------------
;   Restore ST0 and ST1.  Note OBJMODE is
;   the only bit not restored to its reset state.
;   OBJMODE is left set for C28x object operating
;   mode.
;
;  ST0 = 0x0000     ST1 = 0x0A0B
;  15:10 OVC = 0    15:13      ARP = 0
;   9: 7  PM = 0       12       XF = 0
;      6   V = 0       11  M0M1MAP = 1
;      5   N = 0       10  reserved
;      4   Z = 0        9  OBJMODE = 1
;      3   C = 0        8    AMODE = 0
;      2  TC = 0        7 IDLESTAT = 0
;      1 OVM = 0        6   EALLOW = 0
;      0 SXM = 0        5     LOOP = 0
;                       4      SPA = 0
;                       3     VMAP = 1
;                       2    PAGE0 = 0
;                       1     DBGM = 1
;                       0     INTM = 1
;-----------------------------------------------

    MOV  *SP++,#0
    MOV  *SP++,#0x0A0B
    POP  ST1
    POP  ST0

;------------------------------------------------
;   Jump to the EntryAddr as defined by the
;   boot mode selected and continue execution
;-----------------------------------------------

    LRETR

;eof ----------

  • Ron

    The ExitBoot is the same for both devices, so that shouldn't be an issue.

    Are you seeing the device reset at all?

    So you've confirmed (with no debugger connected), that it is running the OTP bootloader, then jumping to the correct address?

    If you connect to the device (make sure the target configuration has no GEL, under advanced settings for target config, click on CPU1 and delete any path to GEL) after this has all happened, where is it?

    Best regards

    Chris

  • Hey Chris,

    Thanks for the reply,  I removed the path to the GEL file (as it was set)  and downloaded another image to OTP (found a pile of scrap boards, 28035, does the same as the 28021 (only had two)  and same code)  -  I have an led turn on when it jumps into the loader as well as spit out char to a terminal display  before it jumps to the application. Led Turns On, but no char comes out.  However, still works if I run via the debugger (download OTP, hit play, and as I long I as don't change any code, I can step through via the debugger as often as I like, does that sound right?).

  • I take that back, LED is already on after a power cycle (drawbacks of different boards, I could see the led toggle when I step through it on the 28021, or cycled power), so how can I tell where it's going?If it's not  jumping into OTP, is there a way to debug that?  

  • Ron,

    Are you testing with the debugger disconnected? If it is connected, the boot sequence won't use the data programmed into OTP.

    You can test with debugger connected if you program the emulation RAM location.

    Additionally, you can load symbols via CCS of the boot ROM. You find the boot ROM OUT image at C:\ti\controlSUITE\libs\utilities\boot_rom

    With the symbols, you can step through and make sure it is going where you expect (in terms of boot flow).

    Best regards

    Chris

  • If I don't have it boot  to OTP (via 0x3D7BFE=0x55AA, 0x3D7BFF=0x006)  but have the boot loader stored in OTP and just let the boot process default to starting up in Flash A (0x3F7FF6)  and have the application in Flash A jump to OTP (0x3D7B54) on startup, all is well and the application runs fine (stored in Flash E-B, 28035) . It Works with  a power cycle or warm reset.   So I guess I'm missing something to get it to jump/run in OTP on a power cycle.

  • Ron

    It sounds like your boot loader in OTP doesn't have its entry point at 0x3D7800? That is where the OTP boot mode is going to branch to when it exits boot.

    Best regards

    Chris

  • Ah, so I need to swap Begin with SCIBOOTINIT?

            SCIBOOTINIT : origin = 0x3D7800, length = 0x000050
            SCIBOOT     : origin = 0x3D7850, length = 0x0002FE
            VERSION     : origin = 0x3D7B50, length = 0x000004    //2 words  // Current Version of BootLoader and date
            BEGIN       : origin = 0x3D7B54, length = 0x000002     /* Used for "boot to Flash" bootloader mode. OTP */
    I just tried the memory browser check, something is definitely amuck when I hit cpu reset, play, and pause..

     

  • So that was it!  Many thanks Chris!, I was totally looking in the wrong place.  Hopefully someone else can learn from my mistake.

    Have a good weekend!,

    Ron.