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: Bootloader issues TMS570LC4357

Part Number: TMS570LC4357
Other Parts Discussed in Thread: TMS570LS0714, TMS570LS0914,

Tool/software:

Hello all,

I am trying to port the Bootloader code I successfully use with another micro of this family (TMS570LS0714) and ran across some issues.

In particular, it seems I was able to solve most of them but I struggle to move on due to an issue with interrupts.

What I am trying to debug the issue right now is simply to add an RTI Compare 0 interrupt that will blink the 2 user led on the dev board, however with the usual bl_Link.cmd file as soon as I call "_enable_IRQ_interrupt" the device goes into bootloop. Below my cmd file and main file where this is executed

Linker:

/* Linker Settings */

--retain="*(.intvecs)"

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

/*----------------------------------------------------------------------------*/
/* Memory Map */
MEMORY
{
/* USER CODE BEGIN (2) */
/* USER CODE END */

VECTORS (X) : origin=0x00000000 length=0x00000020 vfill = 0xffffffff
FLASH0 (RX) : origin=0x00000020 length=0x001FFFE0 vfill = 0xffffffff
FLASH1 (RX) : origin=0x00200000 length=0x00200000 vfill = 0xffffffff
SRAM (RWX) : origin=0x08002000 length=0x0002D000
STACK (RW) : origin=0x08000000 length=0x00002000

/* USER CODE BEGIN (3) */
/*
ECC_VEC (R) : origin=0xf0400000 length=0x4 ECC={algorithm=algoL2R5F021, input_range=VECTORS }
ECC_FLA0 (R) : origin=0xf0400000 + 0x4 length=0x3FFFC ECC={algorithm=algoL2R5F021, input_range=FLASH0 }
ECC_FLA1 (R) : origin=0xf0440000 length=0x40000 ECC={algorithm=algoL2R5F021, input_range=FLASH1 }
*/
#if 1
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 }

ECC_FLA1 (R) : origin=(0xf0400000 + (start(FLASH1) >> 3))
length=(size(FLASH1) >> 3)
ECC={algorithm=algoL2R5F021, input_range=FLASH1 }
#endif
/* USER CODE END */

}

/* USER CODE BEGIN (4) */
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 */
}
/* USER CODE END */

/*----------------------------------------------------------------------------*/
/* Section Configuration */
SECTIONS
{
/* USER CODE BEGIN (5) */
/* USER CODE END */
.intvecs : {} > VECTORS

/* The toot directory is \Debug */
flashAPI:
{
.\source\Fapi_UserDefinedFunctions.obj (.text)
.\source\bl_flash.obj (.text)
--library= "c:\ti\Hercules\F021 Flash API\02.01.01\F021_API_CortexR4_BE_L2FMC.lib" (.text)
} palign=8 load = FLASH0 |FLASH1, run = SRAM, LOAD_START(apiLoadStart), RUN_START(apiRunStart), SIZE(apiLoadSize)

.text : {} palign=8 > FLASH0 |FLASH1 /*Initialized executable code and constants*/
.const : {} palign=8 > load=FLASH0 |FLASH1, run = SRAM, LOAD_START(constLoadStart), RUN_START(constRunStart), SIZE(constLoadSize) /*Initialized constant data (e.g. const flash_sectors[..] = )*/
.cinit : {} palign=8 > FLASH0 |FLASH1 /*Initialized global and static variables*/
.pinit : {} palign=8 > FLASH0 |FLASH1
.data : {} > SRAM
.bss : {} > SRAM
.sysmem : {} > SRAM

/* USER CODE BEGIN (6) */
FEE_TEXT_SECTION : {} > FLASH0 | FLASH1
FEE_CONST_SECTION : {} > FLASH0 | FLASH1
FEE_DATA_SECTION : {} > SRAM
/* USER CODE END */
}

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


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

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

Main File:

#include "bl_config.h"
#include "sci_common.h"

#if defined (CAN_ENABLE_UPDATE)
#include "bl_can.h"
#endif

#if defined (SPI_ENABLE_UPDATE)
#include "bl_spi.h"
#endif

#if defined (UART_ENABLE_UPDATE)
#include "bl_uart.h"
#endif

#if defined (RM57) || defined (TMS570LC43)
#include "HL_het.h"
#include "HL_gio.h"
#include "HL_sci.h"
#include "HL_system.h"
#include "HL_sys_common.h"
#include "HL_sys_core.h"
#else
#include "het.h"
#include "sci.h"
#include "gio.h"
#include "system.h"
#include "sys_common.h"
#include "sys_core.h"
#endif

#include "bl_check.h"
#include "bl_led_demo.h"
#include "HL_rti.h"

uint32_t ms = 0;
/*****************************************************************************
* bl_main
******************************************************************************/
#if defined (SPI_ENABLE_UPDATE) || defined(UART_ENABLE_UPDATE) || defined(CAN_ENABLE_UPDATE)

/*****************************************************************************
*
* This holds the current remaining size in bytes to be downloaded.
*
******************************************************************************/
uint32_t g_ulTransferSize;

/*****************************************************************************
*
* This holds the current address that is being written to during a download
* command.
*
******************************************************************************/
uint32_t g_ulTransferAddress;

/*****************************************************************************
*
* This is the data buffer used during transfers to the boot loader.
*
******************************************************************************/
uint32_t g_pulDataBuffer[BUFFER_SIZE];

/*****************************************************************************
*
* This is the data buffer used for update status.
*
* g_pulUpdateSuccess[] are used to store application update status and application
* image's version etc
******************************************************************************/

uint32_t g_pulUpdateSuccess[8] = {0x5A5A5A5A, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
uint32_t g_ulUpdateStatusAddr = APP_STATUS_ADDRESS;

uint32_t g_ulUpdateBufferSize = 32; /*16 bytes or 4 32-bit words*/

#define E_PASS 0
#define E_FAIL 0x1U
#define E_TIMEOUT 0x2U

/*****************************************************************************
*
* This is an specially aligned buffer pointer to g_pulDataBuffer to make
* copying to the buffer simpler. It must be offset to end on an address that
* ends with 3.
*
******************************************************************************/
uint8_t *g_pucDataBuffer;

extern unsigned int apiLoadStart;
extern unsigned int apiLoadSize;
extern unsigned int apiRunStart;


extern unsigned int constLoadStart;
extern unsigned int constLoadSize;
extern unsigned int constRunStart;


/*****************************************************************************
*
* This holds the current address that is being written to during a download
* command.
*
******************************************************************************/
void delay(unsigned int delayval) {
while(delayval--);
}

//extern void _copyAPI2RAM_(unsigned int* r0, unsigned int* r1, unsigned int* r2);

void main(void)

{
g_pulUpdateSuccess[3] = 0x30002019; /*version number, 03.00, in 2019*/
uint32_t fnRetValue = 0;

/* Initialize SCI Routines to receive Command and transmit data */
sciInit();

gioInit();
/* Initialize RTI driver */
rtiInit();

/* Set high end timer GIO port hetPort pin direction to all output */
gioSetDirection(hetPORT1, 0xFFFFFFFF);

/* Enable RTI Compare 0 interrupt notification */
rtiEnableNotification(rtiREG1,rtiNOTIFICATION_COMPARE0);

/* Enable IRQ - Clear I flag in CPS register */
/* Note: This is usually done by the OS or in an svc dispatcher */
_enable_IRQ_interrupt_();

/* Start RTI Counter Block 0 */
rtiStartCounter(rtiREG1,rtiCOUNTER_BLOCK0);

/* Copy the flash APIs to SRAM*/
//_copyAPI2RAM_(&apiLoadStart, &apiRunStart, &apiLoadSize);
memcpy(&apiRunStart, &apiLoadStart, (uint32)&apiLoadSize);

/* Copy the .const section */
//_copyAPI2RAM_(&constLoadStart, &constRunStart, &constLoadSize);
memcpy(&constRunStart, &constLoadStart, (uint32)&constLoadSize);


#if defined (SPI_ENABLE_UPDATE)
UART_putString(UART, "\r Hercules MCU SPI BootLoader ");
#endif
#if defined (CAN_ENABLE_UPDATE)
UART_putString(UART, "\r Hercules MCU CAN BootLoader ");
#endif
#if defined (UART_ENABLE_UPDATE)
UART_putString(UART, "\r Hercules MCU UART BootLoader ");
#endif

UART_putString(UART, "\r TI DSP Application Team, qjwang@ti.com \r\r");

//
// See if an update should be performed.
//
fnRetValue = CheckForceUpdate();

//fnRetValue = 0; //qj for testing application code

if ( !fnRetValue )
{
#ifdef DEBUG_MSG
UART_putString(UART, "\r Jump to application... ");
#endif
g_ulTransferAddress = (uint32_t)APP_START_ADDRESS;
((void (*)(void))g_ulTransferAddress)();
}

//
// Configure the microcontroller.
//
//EnterBootLoader
#ifdef CAN_ENABLE_UPDATE
ConfigureCANDevice(CAN_PORT);
#endif
#ifdef SPI_ENABLE_UPDATE
ConfigureSPIDevice(SPI_PORT);
#endif
#ifdef UART_ENABLE_UPDATE
ConfigureUartDevice();
#endif

//
// Branch to the update handler. Use can1
//
#ifdef CAN_ENABLE_UPDATE
UpdaterCAN(CAN_PORT);
#endif

#ifdef UART_ENABLE_UPDATE
UpdaterUART();
#endif
#ifdef SPI_ENABLE_UPDATE
UpdaterSPI(SPI_PORT);
#endif

}


/******************************************************************************
*
* Configures the microcontroller.
*
* This function configures the peripherals and GPIOs of the microcontroller,
* preparing it for use by the boot loader. The interface that has been
* selected as the update port will be configured, and auto-baud will be
* performed if required.
*
* \return None.
*
******************************************************************************/
#ifdef SPI_ENABLE_UPDATE
void ConfigureSPIDevice(spiBASE_t *node)
{
//
// Initialize the SPI1 as slave mode
// Enable the SPI interface in slave mode.
// Set the SPI protocol to Motorola with default clock high and data valid on the rising edge.
//
spiInit();
}
#endif

#ifdef UART_ENABLE_UPDATE
void ConfigureUartDevice(void)
{
//
// Enable the the clocks to the UART and GPIO modules.
//
sciInit();
}
#endif

#endif
/* Note-You need to remove rtiNotification from notification.c to avoid redefinition */
void rtiNotification(rtiBASE_t *rtiREG, uint32 notification)
{
/* enter user code between the USER CODE BEGIN and USER CODE END. */
uint8_t val1 = gioGetBit(gioPORTB,6);
uint8_t val2 = gioGetBit(gioPORTB,7);
/* Toggle HET pin 0 */
gioSetBit(gioPORTB,6,(!val1)&1);
gioSetBit(gioPORTB,7,(!val2)&1);
if(++ms >=100000)
ms = 0;
}
/* USER CODE END */

It appears that I am able to get the interrupt working by modifying as follow the linker file:

/* Linker Settings */

--retain="*(.intvecs)"

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

/*----------------------------------------------------------------------------*/
/* Memory Map */
MEMORY
{
/* USER CODE BEGIN (2) */
/* USER CODE END */

VECTORS (X) : origin=0x00000000 length=0x00000020 vfill = 0xffffffff
FLASH0 (RX) : origin=0x00000020 length=0x001FFFE0 vfill = 0xffffffff
FLASH1 (RX) : origin=0x00200000 length=0x00200000 vfill = 0xffffffff
SRAM (RWX) : origin=0x08002000 length=0x0002D000
STACK (RW) : origin=0x08000000 length=0x00002000

/* USER CODE BEGIN (3) */
/*
ECC_VEC (R) : origin=0xf0400000 length=0x4 ECC={algorithm=algoL2R5F021, input_range=VECTORS }
ECC_FLA0 (R) : origin=0xf0400000 + 0x4 length=0x3FFFC ECC={algorithm=algoL2R5F021, input_range=FLASH0 }
ECC_FLA1 (R) : origin=0xf0440000 length=0x40000 ECC={algorithm=algoL2R5F021, input_range=FLASH1 }
*/
#if 1
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 }

ECC_FLA1 (R) : origin=(0xf0400000 + (start(FLASH1) >> 3))
length=(size(FLASH1) >> 3)
ECC={algorithm=algoL2R5F021, input_range=FLASH1 }
#endif
/* USER CODE END */

}

/* USER CODE BEGIN (4) */
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 */
}
/* USER CODE END */

/*----------------------------------------------------------------------------*/
/* Section Configuration */
SECTIONS
{
/* USER CODE BEGIN (5) */
/* USER CODE END */
.intvecs : {} > VECTORS

/* The toot directory is \Debug */
flashAPI:
{
.\source\Fapi_UserDefinedFunctions.obj (.text,.data)
.\source\bl_flash.obj (.text,.data)
--library= "c:\ti\Hercules\F021 Flash API\02.01.01\F021_API_CortexR4_BE_L2FMC.lib" (.text,.data)
} palign=8 load = FLASH0 |FLASH1, run = SRAM, LOAD_START(apiLoadStart), RUN_START(apiRunStart), SIZE(apiLoadSize)

.text : {} palign=8 > FLASH0 |FLASH1 /*Initialized executable code and constants*/
.const : {} palign=8 > FLASH0 |FLASH1//load=FLASH0 |FLASH1, run = SRAM, LOAD_START(constLoadStart), RUN_START(constRunStart), SIZE(constLoadSize) /*Initialized constant data (e.g. const flash_sectors[..] = )*/
.cinit : {} palign=8 > FLASH0 |FLASH1 /*Initialized global and static variables*/
.pinit : {} palign=8 > FLASH0 |FLASH1
.data : {} > SRAM
.bss : {} > SRAM
.sysmem : {} > SRAM

/* USER CODE BEGIN (6) */
FEE_TEXT_SECTION : {} > FLASH0 | FLASH1
FEE_CONST_SECTION : {} > FLASH0 | FLASH1
FEE_DATA_SECTION : {} > SRAM
/* USER CODE END */
}

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


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

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

and commenting this line in the main file:

memcpy(&constRunStart, &constLoadStart, (uint32)&constLoadSize);

I tried this since for TMS570ls0714 this worked fine and I previosuly had to do it for TMS570LS0914. 

But I canot understand what is the problem.

for reference, I downloaded the exaple bootloader and directly loaded the provided example project in CCS for TMS570LC4357 and only enabled the interrupt (RTI Compare 0) and it caused the same bootloop issue.

What could be the cause? is there any issue with my linker file?

Thanks

  • Hello jagadish,

    Sorry I think my problem is a little different.

    rather than having issues on interrupts when in the application (as in the thread) after having it flashed through bootloader, my issue is that the interrupts do not work in the bootloader.

    what I need is use the rti compare 0 interrupt but only way to make the interrupts work is to modify as I mentioned the linker file removing copy of const section.

    the issue now is:

    - that I do not o ow why this modification makes interrupt works

    - I am now stuck when executing function “Fapi_Block_read” functions that make the mI to jump to “dataEntry” and stuck there

    i am not at a point where I can test my app so I cannot say that then the app interrupts will work fine.

    what do you think?

    thanks

  • Hi Alberto,

    My initial findings were:

    1. The TMS570LS0714 device has only single flash bank but we are declaring two flash banks in Linker cmd file.

    2. You are sharing two linker cmd's files right, i hope one for bootloader and other for application. If this is the case then i could see the bootloader and application both are starting at same address of the flash i.e. 0x00000020. It should not be done; bootloader and application should have separate memory sections.

    You can find bootloader example projects in below FAQ, you can refer them once:

    (+) [FAQ] TMS570LC4357: Examples and Demos available for Hercules Controllers (E.g. TMS570x, RM57x and RM46x etc) - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

    --
    Thanks & regards,
    Jagadish.

  • Hello Jagadish,

    thanks for the reply.

    regarding the flash banks, correct the LC4357has two, but I used the bl_link.cmd file in its specific folders of the bootloaders examples so there should not be any conflict. It appears that using the provided example by ti and enabling the interrupt, cause the bootloader not to work. This in bootloader stage, no application has been flashed/tested so far, as I want before to have the bootloader debugged. It seems that the example provided does not allow use of interrupts in the bootloader, do you agree with this?

    regarding the linker file nope, app is starting at address 0x40020 as per another previous implementation. This allow use also of the flash021 api to read and write eeprom params in the device while in bootloader.

    May be the implementation of fapi_bloc_read not correct for the tms570lc4357? Looking at memory browser, I see that the FAPI write function correctly write the app data sent over can at address 0x40020 on, the issue is that in my implementation , as soon as 8 bytes are written, a they are read back from memory to compute a crc that then is sent to the pc app as a integrity check. It seems that it stops in the reading of the 8bytes from flash bank 0

    thanks

  • Hi Alberto,

    Apologies for the delay in the late response.

    It seems that the example provided does not allow use of interrupts in the bootloader, do you agree with this?

    I never tested interrupts on bootloader side, usually i tested interrupts on application side only.

    Is it possible to setup one live debugging session from your end, so that i can understand your use case more thoroughly and can provide my suggestions based on it.

    I will be available from Monday to Friday, from 10AM to 7PM (Indian Standard Time). You can setup a meeting based on your availability.


    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    apologies on my side for the late answer.

    I was not able to solve my issue so it would be ideal if we can setup a meeting so I can show you what I am trying to do. I am living in Italy, Would it work around 5:30-6pm Indian standard Time? Or we can set up at 11:30 AM Indian Standard Time.

    Let me know what work best for you!

    Thanks

  • Can we setup this on Monday 11:30AM Indian Standard Time?