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.

TMS320F28P650DK: Flash_initModule leading to illegal trap while developing CAN bootloader

Part Number: TMS320F28P650DK

Hi Team,linker.txt 

Currently, I am developing a bootloader for TMS320F28P650DK9 following the flow outlined below (which is alredy there for TMS320F228P77s). During boot main initialization when it entering to Flash_initModule, the process enters an illegal trap and does not recover from it. I need support to unblock this situation belw added code start branch file and linker command files ,

 

 

Also addind the linker command file and code start branch file below :

Code Start branch file :
***********************************************************************
     .global boot_main
     .global _entry
     .global __stack_boot
     .global _bootstrap_main
     .global _exit

     .global _start_ebss
     .global _end_ebss
****************************************************************************

****************************************************************************
* Declare the stack.  Size is determined by the linker option -stack.  The *
* default value is 1K words.                                               *
****************************************************************************
__stack_boot:    .usect    ".stack",0
****************************************************************************
*  INITIALIZE RESET VECTOR TO POINT AT _c_int00                            *
****************************************************************************
    .sect .reset
    .long _entry
    .text

****************************************************************************
* FUNCTION DEF : _bootstrap_main                                               *
*                                                                          *
****************************************************************************
_bootstrap_main:    .asmfunc
****************************************************************************
*  CALL USER'S PROGRAM                                                     *
****************************************************************************
    LB      _c_int00            ; execute TI init routines
    ;LCR        _exit
    LB      ExitBoot
    .endasmfunc
****************************************************************************
****************************************************************************
* FUNCTION DEF : _entry                                                  *
*                                                                          *
****************************************************************************
_entry:    .asmfunc
****************************************************************************
*  INITIALIZE STACK POINTER.                                               *
****************************************************************************
    MOV      SP,#__stack_boot        ; set to beginning of stack space
****************************************************************************
* INITIALIZE STATUS BIT FIELDS *NOT* INITIALIZED AT RESET                  *
****************************************************************************
    SPM    0            ; set product shift to 0
****************************************************************************
* SETTING THESE STATUS BITS/REGISTER TO RESET VALUES.  IF YOU RUN          *
* _c_int00 FROM RESET, YOU CAN REMOVE THIS CODE                            *
****************************************************************************
    CLRC    PAGE0            ; use stack addressing mode
    MOVW    DP,#0            ; initialize DP to point at low 64K
    CLRC    OVM                 ; turn off overflow mode
    ASP                ; ensure SP is aligned
****************************************************************************
*  CALL USER'S PROGRAM                                                     *
****************************************************************************
     LCR boot_main            ; execute boot_main()
     LB _bootstrap_main
        .endasmfunc
****************************************************************************
WD_DISABLE  .set  1    ;set to 1 to disable WD, else set to 0
    .ref _c_int00
    .ref main
    .global code_start
    .global ExitBoot
***********************************************************************
* Function: codestart section
*
* Description: Branch to code starting point
***********************************************************************
    .sect "codestart"
    .retain
code_start:
    .if WD_DISABLE == 1
        LB wd_disable       ;Branch to watchdog disable code
    .else
        LB _c_int00         ;Branch to start of boot._asm in RTS library
    .endif

;end codestart section
***********************************************************************
* Function: wd_disable
*
* Description: Disables the watchdog timer
***********************************************************************
    .if WD_DISABLE == 1
    .text
wd_disable:
    SETC OBJMODE        ;Set OBJMODE for 28x object code
    EALLOW              ;Enable EALLOW protected register access
    MOVZ DP, #7029h>>6  ;Set data page for WDCR register
    MOV @7029h, #0068h  ;Set WDDIS bit in WDCR to disable WD
    EDIS                ;Disable EALLOW protected register access
    ;LB _c_int00         ;Branch to start of boot._asm in RTS library
    LCR _entry           ;main in main file here main is there previously
 ; Cleanup and exit.  At this point the EntryAddr
; is located in the ACC register
    LB  ExitBoot
    .endif
;end wd_disable
;-----------------------------------------------
; ExitBoot
;-----------------------------------------------
;-----------------------------------------------
;This module cleans up after the boot loader
;
; 1) Make sure the stack is deallocated.
;    SP = 0x400 after exiting the boot
;    loader
; 2) Push 0 onto the stack so RPC will be
;    0 after using LRETR to jump to the
;    entry point
; 2) Load RPC with the entry point
; 3) Clear all XARn registers
; 4) Clear ACC, P and XT registers
; 5) LRETR - this will also clear the RPC
;    register since 0 was on the stack
;-----------------------------------------------
ExitBoot:
__stack:    .usect ".stack",0
;-----------------------------------------------
;   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 ----------
    .end

;//
;// End of file.
;//