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.

TMS570LC4357: TMS570LC43x Bootloader Transition to RTOS Application: Unexpected SVC Entry

Part Number: TMS570LC4357

Hi

I'm encountering an unexpected behavior while transitioning from a bootloader to a Real-Time Operating System (RTOS) application on the TMS570LC43x microcontroller. Specifically, when jumping from the bootloader code to the RTOS application, the processor's Program Counter (PC) seems to enter an SVC (Supervisor Call) entry instead of directly executing the application code.

Details:

  • Microcontroller: TMS570LC43x
  • Bootloader: Custom bootloader code based on UART, (build upon the TI Bootloader)
  • RTOS: FOXBMS Code using   Free RTOS .
  • Development Environment: Code Composer Studio (CCS) for Bootloader , VS code for Application.
  • Observation: Upon transition from the bootloader to the RTOS application, the PC enters an SVC entry point instead of directly executing the application code.

Questions:

  1. What could be causing the processor to enter the SVC entry upon transitioning from the bootloader to the RTOS application?
  2. Is it normal behavior for an RTOS application to begin execution from an SVC entry point, or does this indicate a potential issue in the application or bootloader setup?
  3. How can I verify that the RTOS initialization routine is being called correctly and that subsequent application tasks are executed as expected?
  4. Are there any specific configuration settings or startup sequence considerations I should be aware of when transitioning from a bootloader to an RTOS application on the TMS570LC43x microcontroller?
  5. Are there any debugging techniques or tools I can use to trace the execution flow and diagnose the cause of the unexpected SVC entry during the transition?

Linker files & .intvecs file is attached.

Bootloader CMD FILE 

/*----------------------------------------------------------------------------*/
/* sys_link.cmd                                                               */
/*                                                                            */

/*----------------------------------------------------------------------------*/
/* Linker Settings                                                            */

--retain="*(.intvecs)"

/* USER CODE BEGIN (1) */
/* USER CODE END */

/*----------------------------------------------------------------------------*/
/* Memory Map                                                                 */

MEMORY
{
/* USER CODE BEGIN (2) */
#if 0
/* USER CODE END */
    VECTORS (X)  : origin=0x00000000 length=0x00000020
    FLASH0  (RX) : origin=0x00000020 length=0x001FFFE0
    FLASH1  (RX) : origin=0x00200000 length=0x00200000
    STACKS  (RW) : origin=0x08000000 length=0x00000800
    RAM     (RW) : origin=0x08000800 length=0x0007f800

/* USER CODE BEGIN (3) */
#endif

#if 1
    VECTORS (X)  : origin=0x00000000 length=0x00000020  fill = 0xffffffff
    FLASH0  (RX) : origin=0x00000020 length=0x001FFFE0 vfill = 0xffffffff
    FLASH1  (RX) : origin=0x00200000 length=0x00200000 vfill = 0xffffffff
    /* Bank 7 (128kB, FEE) */
    FLASH7   (R) : origin=0xF0200000 length=0x00020000 vfill = 0xffffffff

    STACKS  (RW) : origin=0x08000000 length=0x00001500
    RAM     (RW) : origin=0x08001500 length=0x0002EB00
/* Bank 0 ECC */
    ECC_VEC  (R) : origin=(0xf0400000 + (start(VECTORS) >> 3))
                   length=(size(VECTORS) >> 3)
                   ECC={algorithm=algoL2R5F021, input_range=VECTORS}

    ECC_FLA0 (R) : origin=(0xf0400000 + (start(FLASH0)  >> 3))
                   length=(size(FLASH0)  >> 3)
                   ECC={algorithm=algoL2R5F021, input_range=FLASH0 }

/* Bank 1 ECC */
    ECC_FLA1 (R) : origin=(0xf0400000 + (start(FLASH1)  >> 3))
                   length=(size(FLASH1)  >> 3)
                   ECC={algorithm=algoL2R5F021, input_range=FLASH1 }

/* Bank 7 ECC */
    ECC_FLA7 (R) : origin=0xF0100000
                   length=(size(FLASH7)  >> 3)
                   ECC={algorithm=algoL2R5F021, input_range=FLASH7 }
#endif
/* USER CODE END */
}

/* USER CODE BEGIN (4) */
#if 1
ECC {
    algoL2R5F021 : address_mask = 0xfffffff8 /* Address Bits 31:3 */
                   hamming_mask = R4         /* Use R4/R5 build in Mask */
                   parity_mask  = 0x0c       /* Set which ECC bits are Even and Odd parity */
                   mirroring    = F021       /* RM57Lx and TMS570LCx are build in F021 */
}
#endif
/* USER CODE END */


/*----------------------------------------------------------------------------*/
/* Section Configuration                                                      */

SECTIONS
{
/* USER CODE BEGIN (5) */
#if 0
/* USER CODE END */
    .intvecs : {} > VECTORS
    .text   align(32) : {} > FLASH0 | FLASH1
    .const  align(32) : {} > FLASH0 | FLASH1
    .cinit  align(32) : {} > FLASH0 | FLASH1
    .pinit  align(32) : {} > FLASH0 | FLASH1
    .bss     : {} > RAM
    .data    : {} > RAM
    .sysmem  : {} > RAM
	

/* USER CODE BEGIN (6) */
#endif

#if 1
   .intvecs    : {} palign=8 > VECTORS
   flashAPI:
   {
      .\source\Fapi_UserDefinedFunctions.obj (.text, .data)
      .\source\bl_flash.obj (.text, .data)
      --library = F021_API_CortexR4_BE_L2FMC.lib (.text, .data)
   } palign=8 load = FLASH0 |FLASH1, run = RAM, LOAD_START(apiLoadStart), RUN_START(apiRunStart), SIZE(apiLoadSize)

   .text    : {} palign=8 > FLASH0 |FLASH1
   .const   : {} palign=8 load=FLASH0 |FLASH1
   .cinit   : {} palign=8 > FLASH0 | FLASH1
   .pinit   : {} palign=8 > FLASH0 | FLASH1
   .bss     : {} > RAM    /* Uninitialized global and static variables */
   .data    : {} > RAM    /* Global and static non-const variables that are explicitly initialized. */
   .sysmem  : {} > RAM    /* Memory pool (heap) for dynamic memory allocation */
#endif

/* USER CODE END */
}

/* USER CODE BEGIN (7) */
/* USER CODE END */


/*----------------------------------------------------------------------------*/
/* Misc                                                                       */

/* USER CODE BEGIN (8) */
/* USER CODE END */
/*----------------------------------------------------------------------------*/

Bootloader HL_sys_intvecs.asm

 ; HL_sys_intvecs.asm
 
   .sect ".intvecs"
    .arm

;-------------------------------------------------------------------------------
; import reference for interrupt routines

    .ref _c_int00
    .ref phantomInterrupt
    .def resetEntry

;-------------------------------------------------------------------------------
; interrupt vectors

resetEntry
        b   _c_int00
undefEntry
        b   undefEntry
svcEntry
        b   svcEntry
prefetchEntry
        b   prefetchEntry
dataEntry
        b   dataEntry
        b   phantomInterrupt
        ldr pc,[pc,#-0x1b0]
        ldr pc,[pc,#-0x1b0]

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

Application CMD File 

1.linker_script_elf.cmd

 

linker_script_elf.cmd


 * never remove intvecs during linking */
--retain="*(.intvecs)"

/*========== TMS570LC43xx Memory Map ========================================*/

/* docref: SPNS195C - FEBRUARY 2014 - REVISED JUNE 2016
 *  TMS570LC4357 Hercules™ Microcontroller Based on the ARM® Cortex®-R Core SPNS195C
 *  6.9.1 Memory Map Diagram (Page 90)
 *   - Figure 6-9. Memory Map: Flash ECC, OTP and EEPROM accesses) from 0xF000 0000 to 0xF047 FFFF
 *  6.9.2 Memory Map Table (Page 91)
 *   - Table 6-25. Module Registers / Memories Memory Map:
 *     Flash Data Space ECC start:   0xF040 0000
 *     Flash Data Space ECC end:     0xF05F FFFF (but only usable till 0xF047 FFFF, see also memory map)
 */

/* size of flash banks in TMS570LC43xx */
#define FLASH_BANK_SIZE (0x200000)

/* global size of the FLASH memory in the MCU (TMS570LC43xx has 2 flash banks) */
#define GLOBAL_FLASH_SIZE (1 * FLASH_BANK_SIZE)

#define FLASH_BANK0_START_ADDRESS (0x00000000)
#define FLASH_BANK0_END_ADDRESS   (0x001FFFFF)
#define FLASH_BANK1_START_ADDRESS (0x00200000)
#define FLASH_BANK1_END_ADDRESS   (0x003FFFFF)

/* Data ECC area: 0xF0400000 to 0xF0480000 */
#define ECC_DATA_START_ADDRESS (0xF0400000)

/* start address of the vectors table in ARM (if not otherwise defined, i.e., during flashing) */
#define VECTORS_TABLE_START_ADDRESS     (0x00200000) /*(0x00020000)*//*(0x00000000)*/

/* size of RAM in TMS570LC43xx */
#define GLOBAL_RAM_SIZE (0x80000)
/* global start address of RAM in TMS570LC43xx */
#define GLOBAL_RAM_START_ADDRESS (0x08000000)

/*========== Flash section configuration ====================================*/

#define VFILL_FLASH_PATTERN (0xffffffff)

/* size of VER_VERSION_INFORMATION (has to be large enough to accomodate the version struct) */
#define VERSION_INFORMATION_SIZE (0xC0)

/* size of the VECTORS table */
#define VECTORS_TABLE_SIZE (0x20)

/* size of KERNEL (accomodates the OS) */
#define KERNEL_FUNCTIONS_SIZE (0x8000)

/* remaining size of flash bank 0 as at the beginning of flash bank 0 the vector
 * table and version information struct are placed 0x1D7F20*/
#define REMAINING_FLASH_BANK0_SIZE  (FLASH_BANK_SIZE - VECTORS_TABLE_SIZE - KERNEL_FUNCTIONS_SIZE - VERSION_INFORMATION_SIZE )*/

/* program usable flash size is "remaining flash bank0 size + complete flash bank 1 size" */
#define FLASH_SIZE   (0x001F7F1F)

/*========== ECC Flash section configuration ================================*/
/* sizes for ECC */
#define ECC_VECTORS_TABLE_SIZE          (VECTORS_TABLE_SIZE/8)
#define ECC_KERNEL_FUNCTIONS_SIZE       (KERNEL_FUNCTIONS_SIZE/8)
#define ECC_FLASH_SIZE                  (FLASH_SIZE/8)
#define ECC_VERSION_INFORMATION_SIZE    (VERSION_INFORMATION_SIZE/8)

/*========== RAM section configuration ======================================*/

/* The size of the stacks has to be exactly the same as DRIVER.SYSTEM.VAR.RAM_STACK_LENGTH.VALUE from HalCoGen! */
/* The stack consists of:
 * - user stack
 * - supervisor stack
 * - FIQ stack (FIQ: fast interrupt)
 * - IRQ stack (IRQ: normal interrupt)
 * - Abort stack
 * - Undefined stackarm-none-eabi-objcopy -I binary -O ihex foxbms.bin output.hex
 */
#define STACKS_SIZE (0x800)

/* size of the FreeRTOS RAM; TODO does this have to fit to another value? */
#define KERNEL_DATA_SIZE (0x800)

/* size of shared-RAM section for DMA */
#define SHARED_RAM_SIZE (0x2000)

/*========== Memory Layout ==================================================*/
MEMORY
{
    /* FLASH */
    VECTORS_TABLE         (X) : origin = 0x00200000
                                length = 0x20
                                vfill  = VFILL_FLASH_PATTERN
    KERNEL_FUNCTIONS     (RX) : origin = 0x00200020
                                length = 0x8000
                                vfill  = VFILL_FLASH_PATTERN
    FLASH                (RX) : origin = 0x00208020
                                length = 0x0001B7F20
                                vfill  = VFILL_FLASH_PATTERN
    VER_VERSION_INFORMATION  (RX) : origin = 0x003BFF40
                                length = 0xC0
                                vfill  = VFILL_FLASH_PATTERN
    /* RAM */
    STACKS               (RW) : origin = GLOBAL_RAM_START_ADDRESS
                                length = STACKS_SIZE
    KERNEL_DATA          (RW) : origin = end(STACKS)
                                length = KERNEL_DATA_SIZE
    RAM                  (RW) : origin = end(KERNEL_DATA)
                                length = (GLOBAL_RAM_SIZE - STACKS_SIZE - KERNEL_DATA_SIZE - SHARED_RAM_SIZE)
    SHARED_RAM           (RW) : origin = end(RAM)
                                length = SHARED_RAM_SIZE

    ECC_VECTORS_TABLE       (R) : origin = ECC_DATA_START_ADDRESS
                                  length = ECC_VECTORS_TABLE_SIZE
                                  ECC    = { input_range = VECTORS_TABLE }
    ECC_KERNEL_FUNCTIONS    (R) : origin = end(ECC_VECTORS_TABLE)
                                  length = ECC_KERNEL_FUNCTIONS_SIZE
                                  ECC    = { input_range = KERNEL_FUNCTIONS }
    ECC_FLASH               (R) : origin = end(ECC_KERNEL_FUNCTIONS)
                                  length = ECC_FLASH_SIZE
                                  ECC    = { input_range = FLASH }
    ECC_VERSION_INFORMATION (R) : origin = end(ECC_FLASH)
                                  length = ECC_VERSION_INFORMATION_SIZE
                                  ECC    = { input_range = VER_VERSION_INFORMATION }
}

/*========== ECC Algorithm Configuration ====================================*/
ECC
{
   algo_name : address_mask = 0xfffffff8
   hamming_mask = R4
   parity_mask = 0x0c
   mirroring = F021
}

/*========== Section Layout =================================================*/
SECTIONS
{
    .intvecs                      : {} > VECTORS_TABLE
    /* FreeRTOS Kernel in protected region of Flash */
    .kernelTEXT         align(32) : {} > KERNEL_FUNCTIONS
    .cinit              align(32) : {} > KERNEL_FUNCTIONS
    /* Rest of code to user mode flash region */
    .versionInformation align(32) : {} > VER_VERSION_INFORMATION
    .syscallTEXT        align(32) : {} > FLASH
    .text               align(32) : {} > FLASH
    .const              align(32) : {} > FLASH
    /* FreeRTOS Kernel data in protected region of RAM */
    .kernelBSS                    : {} > KERNEL_DATA
    .bss                          : {} > RAM
    .data                         : {} > RAM
    .sysmem                       : {} > RAM
    .sharedRAM                    : {} > SHARED_RAM
}

2.linker_script_hex.cmd

/*linker_script_hex.cmd*/

/* Aligned with names in "MEMORY" in the elf-linker script */
ROMS
{
    /* FLASH */
    VECTORS_TABLE           : origin = 0x00200000/*0x00020000*//*0x00000000*/
                              length = 0x20
                              fill   = 0xFFFFFFFF
    KERNEL_FUNCTIONS        : origin = 0x00200020
                              length = 0x8000
                              fill   = 0xFFFFFFFF
    FLASH                   : origin = 0x00208020 /*(0x00000000 + 0x20 + 0x8000)*/
                              length = 0x0001B7F20 /*0x3F7F20 //3D 7F20    1966034 */
                              fill   = 0xFFFFFFFF
    VER_VERSION_INFORMATION : origin = 0x003BFF40 /*0x0001FFF40 *//*0x003FFF40(0x00000000 + 0x20 + 0x8000 + 0x3F7F20)   // arj*32 FF40/  0x003FFF40*/
                              length = 0xC0
                              fill   = 0xFFFFFFFF
    /* RAM */
    STACKS                  : origin = 0x08000000
                              length = 0x800
    KERNEL_DATA             : origin = 0x08000800
                              length = 0x800
    RAM                     : origin = 0x08001000
                              length = 0x7D000
    SHARED_RAM              : origin = 0x0807E000
                              length = 0x2000

    ECC_VECTORS_TABLE       : origin = 0xF0400000
                              length = 0x4
    ECC_KERNEL_FUNCTIONS    : origin = 0xF0400004
                              length = 0x1000
    ECC_FLASH               : origin = 0xF0401004
                              length = 0x7EFE4
    ECC_VERSION_INFORMATION : origin = 0xF047FFE8
                              length = 0x18

}

Any insights or guidance on resolving this issue would be greatly appreciated. Thank you!

  • Hi Arjun,

    I started working on this thread and will provide you an update ASAP.

    --
    Thanks & regards,
    Jagadish.

  • Hi Arjun,

    After verifying CMD files of bootloader and application i could see that the RAM areas are overlapping between bootloader and application.

    So, on the application can you please change the RAM start address as below:

    #define GLOBAL_RAM_START_ADDRESS (0x08030000)

    --
    Thanks & regards,
    Jagadish.

  • hi  Jagadish , 

     Thanks for your time. Let me try the above change .  

  • Hi Jagadish , 

     after remapping the RAM Section then also SCV error,

    successful download of Application.bin in to Bank1, the Bootloader is execute the Below CMD .

    JumpAddress = (uint32_t)APP_START_ADDRESS; //0x00200000
    ((void (*)(void))JumpAddress)();

     when i checked with the Debugger  SVC error  is occurring. ( (in Bootloader HL_sys_intvecs.asm).

    Please provide your input to solve this issue.  

  • Hi Arjun,

    Is it possible for you to share the entire application, so that i can trigger the issue at my end and can do the necessary debugging.

    Even you can send a private message to me with the project.

    --

    Thanks & regards,
    Jagadish.

  • hi 

     i have debugged my code ,after changing the RAM selection the Application is running , i have verified with below code .

    int main(void) {
        MINFO_SetResetSource(getResetSource()); /* Get reset source and clear respective flags */
        _enable_IRQ_interrupt_();
        muxInit();
        gioInit();
        SPI_Initialize();
        adcInit();
        hetInit();
        etpwmInit();
        crcInit();
        LED_SetDebugLed();
        I2C_Initialize();
        DMA_Initialize();
        PWM_Initialize();
        DIAG_Initialize(&diag_device);
        MATH_StartupSelfTest();
        const STD_RETURN_TYPE_e checkTimeHasPassedSelfTestReturnValue = OS_CheckTimeHasPassedSelfTest();
        FAS_ASSERT(checkTimeHasPassedSelfTestReturnValue == STD_OK);
        // LED_Trigger();
        // LED_SetToggleTime(LED_NORMAL_OPERATION_ON_OFF_TIME_ms);
        // LED_Trigger();
    
        OS_InitializeOperatingSystem();
    
        if (OS_INIT_PRE_OS != os_boot) {
            /* Could not create Queues, Mutexes, Events and Tasks do not boot further from this point on */
            FAS_ASSERT(FAS_TRAP);
        }
    
        if (STD_OK != CHK_ValidateChecksum()) {
            if (DIAG_HANDLER_RETURN_OK != DIAG_Handler(DIAG_ID_FLASHCHECKSUM, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u)) {
                /* Could not validate checksum do not boot further from this point on */
                FAS_ASSERT(FAS_TRAP);
            }
        }
    
        os_schedulerStartTime = OS_GetTickCount();
         int count             = 1000000;
         while (count--) {
             if (count % 1000 == 0) {
                 if (STD_PIN_HIGH == IO_PinGet(&hetREG1->DIN, 1)) {
                     IO_PinReset(&hetREG1->DOUT, 1);
                 } else {
                     IO_PinSet(&hetREG1->DOUT, 1);
                 }
                 if (count == 999999)
                     count = 1000000;
                 for (int i = 0; i <= 9999999; i++)
                     ;
             }
         }
    
        //OS_StartScheduler(); 
        /* we must never get here; there is no way to determine the exit state of this program,
         * but for the sake of correctness we exit with an error code */
        return 1;
    }
    

    the above code is working file my LED is Blinking properly .

    but when i run the below code then no response .

    int main(void) {
        MINFO_SetResetSource(getResetSource()); /* Get reset source and clear respective flags */
        _enable_IRQ_interrupt_();
        muxInit();
        gioInit();
        SPI_Initialize();
        adcInit();
        hetInit();
        etpwmInit();
        crcInit();
        LED_SetDebugLed();
        I2C_Initialize();
        DMA_Initialize();
        PWM_Initialize();
        DIAG_Initialize(&diag_device);
        MATH_StartupSelfTest();
        const STD_RETURN_TYPE_e checkTimeHasPassedSelfTestReturnValue = OS_CheckTimeHasPassedSelfTest();
        FAS_ASSERT(checkTimeHasPassedSelfTestReturnValue == STD_OK);
        // LED_Trigger();
        // LED_SetToggleTime(LED_NORMAL_OPERATION_ON_OFF_TIME_ms);
        // LED_Trigger();
    
        OS_InitializeOperatingSystem();
    
        if (OS_INIT_PRE_OS != os_boot) {
            /* Could not create Queues, Mutexes, Events and Tasks do not boot further from this point on */
            FAS_ASSERT(FAS_TRAP);
        }
    
        if (STD_OK != CHK_ValidateChecksum()) {
            if (DIAG_HANDLER_RETURN_OK != DIAG_Handler(DIAG_ID_FLASHCHECKSUM, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u)) {
                /* Could not validate checksum do not boot further from this point on */
                FAS_ASSERT(FAS_TRAP);
            }
        }
    
        os_schedulerStartTime = OS_GetTickCount();
       
    
        OS_StartScheduler();
        /* we must never get here; there is no way to determine the exit state of this program,
         * but for the sake of correctness we exit with an error code */
        return 1;
    }
    
     

    when  it hits the 

    OS_StartScheduler();
    not running forward  or no responses.no can message nothing is running.  
     Please help me in this. 
    thanks 
  • Hi Arjun,

    I verified your linker file of application, and it looks fine for me.

    OS_StartScheduler();
    not running forward  or no responses.no can message nothing is running.  

    No idea why it is not working now. Can you please do a private message with your complete projects of both bootloader and application for debugging at my end.

    --
    Thanks & regards,
    Jagadish.

  • Hi  Jagadish ,

    Please check the Inbox , i have shared the codes over there.