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.

TMS570LS3137: Jump from App to Bootloader

Part Number: TMS570LS3137

Hello. I have a question. I was able to get the bootloader working. The bootloader jump well to the application.

My queestion now is how to make it go back to the bootloader from the application.

Try the followong commands, but  all these are reset by  returning to the application, not returning to the bootloader.

((void (*)(void))0x00000000)();

systemREG1->SYSECR=0x0000C000;

I leave my .cmd files.

Bootloader:

--retain="*(.intvecs)"

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

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

MEMORY
{

VECTORS (X) : origin=0x00000000 length=0x00000020 vfill = 0xffffffff
FLASH0 (RX) : origin=0x00000020 length=0x00010000 vfill = 0xffffffff
FLASH1 (RX) : origin=0x00010020 length=0x07FF1FE0 vfill = 0xffffffff
SRAM (RWX) : origin=0x08002000 length=0x00002000
STACK (RW) : origin=0x08004000 length=0x00002000

/* USER CODE BEGIN (2) */
#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 (3) */
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
{
.intvecs : {} > VECTORS


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_V3D16.lib" (.text)
--library="F021_API_CortexR4_BE_V3D16.lib" (.text)
} palign=8 load = FLASH0, run = SRAM, LOAD_START(apiLoadStart), RUN_START(apiRunStart), SIZE(apiLoadSize)

.text : {} > FLASH0 /*Initialized executable code and constants*/
.const : {} load=FLASH0, run = SRAM, LOAD_START(constLoadStart), RUN_START(constRunStart), SIZE(constLoadSize)


.cinit : {} > FLASH0 | FLASH1
.pinit : {} > FLASH0 | FLASH1
.bss : {} > SRAM
.data : {} > SRAM
.sysmem : {} > SRAM
/* USER CODE BEGIN (4) */
/* USER CODE END */
}



Application:

/*----------------------------------------------------------------------------*/
--retain="*(.intvecs)"

/* USER CODE BEGIN (1) */
/* USER CODE END */
/*----------------------------------------------------------------------------*/
/* Memory Map */

MEMORY
{
VECTORS (X) : origin=0x00020020 length=0x00000020
FLASH_CODE (RX) : origin=0x00020040 length=0x008000-0x40 fill=0xFFFFFFFF
FLASH0 (RX) : origin=0x00028000 length=0x180000-0x28000
STACKS (RW) : origin=0x08000000 length=0x00001500
RAM (RW) : origin=0x08001500 length=0x0003EB00

/* USER CODE BEGIN (2) */
/* USER CODE END */
}

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

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

SECTIONS
{
.intvecs : {} > VECTORS
.text : {} > FLASH_CODE
.const : {} > FLASH_CODE
.cinit : {} > FLASH_CODE
.pinit : {} > FLASH_CODE
.bss : {} > RAM
.data : {} > RAM
.sysmem : {} > RAM


/* USER CODE BEGIN (4) */
/* USER CODE END */
}


Thanks a lot !!

  • Hi,

    ((void (*)(void))0x00000000)(); will switch to bootloader. The code will jump to application again after checking the magic number at 0x10000.

    Your bootloader can write the magic number to EEPROM, and application changes the magic number if application update is needed.

    For example there is 4 blocks data FEE, 1st block is magic number, it's length is 8 bytes. After application is updated, the bootloader programs 0x5a5a5a5a5a5a5a5a to block #1. After SW reset, bootloader reads the magic number and jumps to application if the magic number = 0x5a5a5a...5a.

    The application can write 0xa5a5a5a5...a5 to block #1, then jump to bootloader by calling ((void (*)(void))0x00000000)(). Bootloader will update the application since the magic number is not 0x5a5a...5a.