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.

TMS320F28388D: how to write data into the flash when the program and data on it are running?

Part Number: TMS320F28388D

Dear support,

Now I can write the flash space,

specific addresses can be written with specific value.

but it looks like that the flash can not write itself when it's running.

I use the following cmd file to load the program on flash, and run it on RAM.

GROUP
{
.TI.ramfunc
{ -l F2838x_C28x_FlashAPI.lib}
//.const
//.switch
//.init_array
//.cinit

} LOAD = FLASH4 ,
RUN = RAMGS2_13,
LOAD_START(RamfuncsLoadStart),
LOAD_SIZE(RamfuncsLoadSize),
LOAD_END(RamfuncsLoadEnd),
RUN_START(RamfuncsRunStart),
RUN_SIZE(RamfuncsRunSize),
RUN_END(RamfuncsRunEnd),
ALIGN(8)

  • But  how should I take care of the .cinit section and .const section, etc?

    Now matter how I revise the .cmd file, the program always enters an error state after loading the program.

    please see the attached errors.

  • Dear support,

    Please see the following link for my previous work.

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1094241/tms320f28388d-how-to-write-a-binary-file-into-flash-in-my-own-application-code

    now the copyData() is working well when it's running on RAM.

    but how can I update the flash when the program is running on flash?

    I would like load all the sections including functions, text. .cinit, .const, etc(ALL) from FLASH, and run them all on RAM.

    it's not working.

    please see my .cmd file as follows,

    Could you please give some clues? Thanks very much.


    MEMORY
    {
    /* BEGIN is used for the "boot to Flash" bootloader mode */
    BEGIN : origin = 0x080000, length = 0x000002
    BOOT_RSVD : origin = 0x000002, length = 0x0001AF /* Part of M0, BOOT rom will use this for stack */
    RAMM0 : origin = 0x0001B1, length = 0x00024F
    RAMM1 : origin = 0x000400, length = 0x0003F8 /* on-chip RAM block M1 */
    // RAMM1_RSVD : origin = 0x0007F8, length = 0x000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    RAMD0_1 : origin = 0x00C000, length = 0x001000
    // RAMD1 : origin = 0x00C800, length = 0x000800
    //RAMLS0 : origin = 0x008000, length = 0x000800
    //RAMLS1 : origin = 0x008800, length = 0x000800
    //RAMLS2 : origin = 0x009000, length = 0x000800
    RAMLS03 : origin = 0x008000, length = 0x002000
    RAMLS4 : origin = 0x00A000, length = 0x000800
    RAMLS5 : origin = 0x00A800, length = 0x000800
    RAMLS6_7 : origin = 0x00B000, length = 0x001000
    //RAMLS7 : origin = 0x00B800, length = 0x000800
    //RAMLS_TOTAL : origin = 0x008000, length = 0x4000

    RAMGS0 : origin = 0x00D000, length = 0x001000
    RAMGS1 : origin = 0x00E000, length = 0x001000
    //RAMGS2 : origin = 0x00F000, length = 0x001000
    //RAMGS3 : origin = 0x010000, length = 0x001000
    //RAMGS4 : origin = 0x011000, length = 0x001000
    //RAMGS5 : origin = 0x012000, length = 0x001000
    //RAMGS6 : origin = 0x013000, length = 0x001000
    //RAMGS7 : origin = 0x014000, length = 0x001000
    //RAMGS8 : origin = 0x015000, length = 0x001000
    //RAMGS9 : origin = 0x016000, length = 0x001000
    RAMGS2_13 : origin = 0x00F000, length = 0x00C000

    // RAMGS10 : origin = 0x017000, length = 0x001000
    // RAMGS11 : origin = 0x018000, length = 0x001000
    // RAMGS12 : origin = 0x019000, length = 0x001000
    // RAMGS13 : origin = 0x01A000, length = 0x001000
    RAMGS14 : origin = 0x01B000, length = 0x001000
    RAMGS15 : origin = 0x01C000, length = 0x000FF8
    // RAMGS15_RSVD : origin = 0x01CFF8, length = 0x000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */

    /* Flash sectors */
    FLASH0 : origin = 0x080002, length = 0x001FFE /* on-chip Flash */
    FLASH1 : origin = 0x082000, length = 0x002000 /* on-chip Flash */
    FLASH2 : origin = 0x084000, length = 0x002000 /* on-chip Flash */
    FLASH3 : origin = 0x086000, length = 0x002000 /* on-chip Flash */
    FLASH4 : origin = 0x088000, length = 0x008000 /* on-chip Flash */
    FLASH5 : origin = 0x090000, length = 0x008000 /* on-chip Flash */
    FLASH6 : origin = 0x098000, length = 0x008000 /* on-chip Flash */
    FLASH7 : origin = 0x0A0000, length = 0x008000 /* on-chip Flash */
    FLASH8 : origin = 0x0A8000, length = 0x008000 /* on-chip Flash */
    FLASH9 : origin = 0x0B0000, length = 0x008000 /* on-chip Flash */
    FLASH10 : origin = 0x0B8000, length = 0x002000 /* on-chip Flash */
    FLASH11 : origin = 0x0BA000, length = 0x002000 /* on-chip Flash */
    FLASH12 : origin = 0x0BC000, length = 0x002000 /* on-chip Flash */
    FLASH13 : origin = 0x0BE000, length = 0x001FF0 /* on-chip Flash */
    // FLASH13_RSVD : origin = 0x0BFFF0, length = 0x000010 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    /*
    CPU1TOCPU2RAM : origin = 0x03A000, length = 0x000800
    CPU2TOCPU1RAM : origin = 0x03B000, length = 0x000800
    */
    CPU1TOCPU2RAM1 : origin = 0x03A000, length = 0x000088
    CPU1TOCPU2RAM2 : origin = 0x03A088, length = 0x000778
    CPU2TOCPU1RAM1 : origin = 0x03B000, length = 0x000088
    CPU2TOCPU1RAM2 : origin = 0x03B088, length = 0x000778
    CPUTOCMRAM : origin = 0x039000, length = 0x000800
    CMTOCPURAM : origin = 0x038000, length = 0x000800

    CANA_MSG_RAM : origin = 0x049000, length = 0x000800
    CANB_MSG_RAM : origin = 0x04B000, length = 0x000800

    RESET : origin = 0x3FFFC0, length = 0x000002
    }

    SECTIONS
    {
    codestart : > BEGIN, ALIGN(8)
    .text : >> FLASH4, ALIGN(8)
    // for_print{rts2800_fpu64_eabi.lib<_printfi.c.obj>(.text)} RAMGS2_13
    // .cinit : > FLASH7, ALIGN(8)
    //.wwitch : > FLASH5, ALIGN(8)
    GROUP
    {
    .switch
    .cinit
    } LOAD = FLASH5,
    RUN = RAMGS15,
    LOAD_START(_cinit_loadstart),
    RUN_START(_cinit_runstart),
    SIZE(_cinit_size)


    .reset : > RESET, TYPE = DSECT /* not used, */
    .stack : > RAMD0_1 //RAMM1


    .init_array : > FLASH5, ALIGN(8)


    .bss : > RAMLS5
    .bss:output : > RAMLS4
    .bss:cio : > RAMLS5
    .data : > RAMGS2_13
    // .data :>> FLASH4
    .sysmem : > RAMGS2_13 //RAMLS5
    /* Initalized sections go in Flash */
    //.const : > FLASH5, ALIGN(8)
    .const : > FLASH4, ALIGN(8)


    ramgs0 : > RAMGS0, type=NOINIT
    ramgs1 : > RAMGS1, type=NOINIT
    /*
    MSGRAM_CPU1_TO_CPU2 : > CPU1TOCPU2RAM, type=NOINIT
    MSGRAM_CPU2_TO_CPU1 : > CPU2TOCPU1RAM, type=NOINIT
    */
    MSGRAM_CPU1_TO_CPU2 > CPU1TOCPU2RAM1, type=NOINIT
    MSGRAM_DATA_CPU1_TO_CPU2 > CPU1TOCPU2RAM2, type=NOINIT
    MSGRAM_CPU2_TO_CPU1 > CPU2TOCPU1RAM1, type=NOINIT
    MSGRAM_DATA_CPU2_TO_CPU1 > CPU2TOCPU1RAM2, type=NOINIT

    MSGRAM_CPU_TO_CM : > CPUTOCMRAM, type=NOINIT
    MSGRAM_CM_TO_CPU : > CMTOCPURAM, type=NOINIT

    GROUP
    {
    .TI.ramfunc
    { -l F2838x_C28x_FlashAPI.lib}

    } LOAD = FLASH4 ,
    RUN = RAMGS2_13,
    LOAD_START(RamfuncsLoadStart),
    LOAD_SIZE(RamfuncsLoadSize),
    LOAD_END(RamfuncsLoadEnd),
    RUN_START(RamfuncsRunStart),
    RUN_SIZE(RamfuncsRunSize),
    RUN_END(RamfuncsRunEnd),
    ALIGN(8)


    isrfunc : LOAD = FLASH4,
    RUN = RAMM0 | RAMM1 |RAMGS2_13 | RAMLS6_7,
    LOAD_START(isrfuncLoadStart),
    LOAD_SIZE(isrfuncLoadSize),
    LOAD_END(isrfuncLoadEnd),
    RUN_START(isrfuncRunStart),
    RUN_SIZE(isrfuncRunSize),
    RUN_END(isrfuncRunEnd),
    PAGE = 0, ALIGN(8)

    }

    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */

  • Hi Ping Zhou,

    Are you willing to move the flash API to RAM or your application as well to RAM?

    If I understand correctly, you want to move only the flash API to RAM - correct?

    Thanks and regards,
    Vamsi

  • Dear Vamsi,

    My purpose is to update the flash, please see my previous work as follows,

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1094241/tms320f28388d-how-to-write-a-binary-file-into-flash-in-my-own-application-code

    after flash is updated, the program also can update the flash again and again.

    I would like to move all the flash writing related application to RAM.

    My experiment shows that if only the flash APIs are moved to RAM, the program will enter error, because some constant data in flash are written to another value(in my opinion).

    so I think the .cinit and .const, etc are all supposed to be moved to RAM.

    Thanks very much!

  • Hi Ping Zhou,

    Did you map all the functions that call flash API as well to RAM (as shown in the flash API usage example and mentioned in the flash API guide)?

    Are you erasing any sectors to which the flash API is mapped?

    Thanks and regards,

    Vamsi

  • Hi Ping Zhou,

    Do you still need help on this?  

    Thanks and regards,
    Vamsi