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.

RTOS/CC1310: Program two applications in the flash

Part Number: CC1310

Tool/software: TI-RTOS

Hi,

I need some guidance on how to program two applications in the flash of a CC1310.

I am using a CC1310 Launchpad.

Until now, I did the following:

1. Create a simple project in the Code Composer Studio which blinks the red led. The project is called bootloader.

2. Create a simple project in the Code Composer Studio which blinks the green led. The project is called application.

3. In the .cfg file, comment the ROM configuration in both bootloader and application.

/* ================ ROM configuration ================ */
/*
 * To use BIOS in flash, comment out the code block below.
 */
/*
var ROM = xdc.useModule('ti.sysbios.rom.ROM');
if (Program.cpu.deviceName.match(/CC26/)) {
    ROM.romName = ROM.CC2650;
}
else if (Program.cpu.deviceName.match(/CC13/)) {
    ROM.romName = ROM.CC1350;
}
*/

4. Leave the .cmd file of the bootloader as it is.

/*
 *  ======== CC1310_LAUNCHXL.cmd ========
 *  CC26x0F128 PG2 linker configuration file for Code Composer Studio
 */

/* Override default entry point.                                             */
--entry_point ResetISR
/* Allow main() to take args                                                 */
--args 0x8
/* Suppress warnings and errors:                                             */
/* - 10063: Warning about entry point not being _c_int00                     */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object  */
/*   files compiled using Keil (ARM compiler)                                */
--diag_suppress=10063,16011,16012

/* The starting address of the application.  Normally the interrupt vectors  */
/* must be located at the beginning of the application.                      */
#define FLASH_BASE              0x0
#define FLASH_SIZE              0x20000
#define RAM_BASE                0x20000000
#define RAM_SIZE                0x5000

/* System memory map */

MEMORY
{
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE
}

/* Section allocation in memory */

SECTIONS
{
    .text           :   > FLASH
    .const          :   > FLASH
    .constdata      :   > FLASH
    .rodata         :   > FLASH
    .cinit          :   > FLASH
    .pinit          :   > FLASH
    .init_array     :   > FLASH
    .emb_text       :   > FLASH
    .ccfg           :   > FLASH (HIGH)

#ifdef __TI_COMPILER_VERSION__
#if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc     : {} load=FLASH, run=SRAM, table(BINIT)
#endif
#endif
    .data           :   > SRAM
    .bss            :   > SRAM
    .sysmem         :   > SRAM
    .stack          :   > SRAM (HIGH)
    .nonretenvar    :   > SRAM
}

5. Change the flash address of the application in the .cmd file.

/*
 *  ======== CC1310_LAUNCHXL.cmd ========
 *  CC26x0F128 PG2 linker configuration file for Code Composer Studio
 */

/* Override default entry point.                                             */
--entry_point ResetISR
/* Allow main() to take args                                                 */
--args 0x8
/* Suppress warnings and errors:                                             */
/* - 10063: Warning about entry point not being _c_int00                     */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object  */
/*   files compiled using Keil (ARM compiler)                                */
--diag_suppress=10063,16011,16012

/* The starting address of the application.  Normally the interrupt vectors  */
/* must be located at the beginning of the application.                      */
#define FLASH_BASE              0x10000 //0x0
#define FLASH_SIZE              0x10000 //0x20000
#define RAM_BASE                0x20000000
#define RAM_SIZE                0x5000

/* System memory map */

MEMORY
{
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE
}

/* Section allocation in memory */

SECTIONS
{
    .text           :   > FLASH
    .const          :   > FLASH
    .constdata      :   > FLASH
    .rodata         :   > FLASH
    .cinit          :   > FLASH
    .pinit          :   > FLASH
    .init_array     :   > FLASH
    .emb_text       :   > FLASH
    .ccfg           :   > FLASH (HIGH)

#ifdef __TI_COMPILER_VERSION__
#if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc     : {} load=FLASH, run=SRAM, table(BINIT)
#endif
#endif
    .data           :   > SRAM
    .bss            :   > SRAM
    .sysmem         :   > SRAM
    .stack          :   > SRAM (HIGH)
    .nonretenvar    :   > SRAM
}

6. Change the reset vector address of the application in the .cfg file.

/*
 * Assign an address for the reset vector.
 *
 * Default is 0x0, which is the start of Flash. Ordinarily this setting should
 * not be changed.
 */
m3Hwi.resetVectorAddress = 0x10000; //0x0;

7. Program the bootloader in the CC1310 using the Code Composer Studio.

8. Program the application in the CC1310 using the Code Composer Studio.

After all that, when I turn on the launchpad it starts blinking the red led (which represents the bootloader). It works as expected.

Now, the questions:

1. Are the steps I made correct?

2. I will add a button function in the bootloader and I would like to jump to application when the button is pressed. How can I do that jump?

  • I managed to do the jump using:

    // Load address of reset function from the fixed location of the image's
    // reset vector and jump.
    asm(" MOV R0, #0x10000 ");
    asm(" LDR R1, [R0, #0x4] ");
    
    // Reset the stack pointer,
    asm(" LDR SP, [R0, #0x0] ");
    
    // And jump.
    asm(" BX R1 ");

    But I still would like to hear your feedback about the whole process:

    1. Are the steps I made correct?

  • Hi,

    As explained before, I burned both bootloader and application in the CC1310 flash memory using the Code Composer Studio.

    Now, I made a routine in the bootloader which receives a file in the UART and stores it in a defined address of the CC1310 flash memory.

    I would like to know which file I should send to properly replace the original application in the CC1310 memory.

    Inside the project Debug folder I have: application.out and application.hex. Which one should I use?

    Best regards,

  • Hi Mad River,

    Neither.

    The .hex file already contains addresses to place in the flash (you just want to copy raw data).

    The .out file contains a lot of information usable for different tool chain, the image is just part of the file.

    You want to generate a binary file (.bin) which will only contain the raw data.

    The binary can either be generated by the tool chain (I haven't found where to do it in CCS; maybe someone from TI can guide you). IT can also be converted from the HEX file with various hex2bin utils found online or you can use the Python IntelHex package.

    Take a look at this thread where I got most of the info.

    Regards,

    Michel

  • Michel Solecki said:

    Hi Mad River,

    Neither.

    The .hex file already contains addresses to place in the flash (you just want to copy raw data).

    The .out file contains a lot of information usable for different tool chain, the image is just part of the file.

    You want to generate a binary file (.bin) which will only contain the raw data.

    The binary can either be generated by the tool chain (I haven't found where to do it in CCS; maybe someone from TI can guide you). IT can also be converted from the HEX file with various hex2bin utils found online or you can use the Python IntelHex package.

    Take a look at this thread where I got most of the info.

    CC1310: About bootloader and firmware update

    TI E2E Community
    HI: I am trying to use USB->UART adapter to CC1310 UART to program the flash. I have read swra466af.pdf and many relative posts on this fortum already. But I still have some question: 1. CC1310 enters bootloader mode just only in this two condition...

    Regards,

    Michel

    Thank you!

    I will try to generate the .bin file.

    Best regards,

  • Mad River,

    Your approach looks correct. It is the same technique we use in our examples.

    I have only one small comment. I would modify the boot loader memory map such that it does not overlap with the application memory map. Right now, you are allocating the full 128KiB Flash to the boot loader. But the application memory map is using the upper 64KiB of Flash. I would reduce the boot loader memory map to only use the lower 64KibB of Flash.

    boot loader
    BASE: 0x00000000
    SIZE: 0x10000

    application
    BASE: 0x00010000
    SIZE: 0x10000

    You can modify the CCS project to generate the .bin file automatically. Add the following command to your post-build steps.

    Project > Properties
    CCS Build > Steps (tab) > Post-build steps

    Add the following as one line:

    ${CCS_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin ${BuildArtifactFileName} ${BuildArtifactFileBaseName}.bin ${CG_TOOL_ROOT}/bin/armofd ${CG_TOOL_ROOT}/bin/armhex ${CCS_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin

    Good luck with your project.
    ~Ramsey

  • Ramsey said:

    Mad River,

    Your approach looks correct. It is the same technique we use in our examples.

    I have only one small comment. I would modify the boot loader memory map such that it does not overlap with the application memory map. Right now, you are allocating the full 128KiB Flash to the boot loader. But the application memory map is using the upper 64KiB of Flash. I would reduce the boot loader memory map to only use the lower 64KibB of Flash.

    boot loader
    BASE: 0x00000000
    SIZE: 0x10000

    application
    BASE: 0x00010000
    SIZE: 0x10000

    You can modify the CCS project to generate the .bin file automatically. Add the following command to your post-build steps.

    Project > Properties
    CCS Build > Steps (tab) > Post-build steps

    Add the following as one line:

    ${CCS_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin ${BuildArtifactFileName} ${BuildArtifactFileBaseName}.bin ${CG_TOOL_ROOT}/bin/armofd ${CG_TOOL_ROOT}/bin/armhex ${CCS_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin

    Good luck with your project.
    ~Ramsey

    Thank you for your feedback.

    Now, the bootloader needs to receive the .bin file containing a new application and replace the original application stored at address 0x00010000.

    I created a new thread about it: 

    Can you give me some help?