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.

TMS320F28384S: CM - .vtable RAM section in generated output file

Part Number: TMS320F28384S
Other Parts Discussed in Thread: C2000WARE

Hello,
I am developing a bootloader on CM core.

The bootloader must run in RAM, so I have copied in RAM the .text and .const sections of all the necessary object modules.

I have also omitted the pre-processor symbol _FLASH in the project, to make vectorTableRAM[] used instead of vectorTableFlash[].

.vftable : > CMBANK0_SECTOR0, ALIGN(16) /* Application placed vector table in Flash*/
.vtable : > S0RAM /* Application placed vector table in RAM*/

I have enabled the .hex output file generation and I have seen that .vtable section is added to the .hex file, even if it resides in RAM.

:020000042000DA
:2008000000C1FF1F01002000290D0120270D0120250D0120250D0120250D01200000000033
:20082000000000000000000000000000250D0120250D012000000000250D0120250D01206C
:20084000250D0120250D0120250D0120250D0120250D0120250D0120250D0120250D012000
:20086000250D0120250D0120250D0120250D0120250D0120250D0120250D0120250D0120E0
:20088000250D0120250D0120250D0120250D0120250D0120250D0120250D0120250D0120C0
:2008A000250D0120250D0120250D0120250D0120250D0120250D0120250D0120250D0120A0
:2008C000250D0120250D0120250D0120250D0120250D0120250D0120250D0120250D012080
:2008E000250D0120250D0120250D0120250D0120250D0120250D0120250D0120250D012060
:20090000250D0120250D0120250D0120250D0120250D0120250D0120250D0120250D01203F
:20092000250D0120250D0120250D0120250D0120250D0120250D0120250D0120250D01201F

I use the .hex file for firmware update and so I expect that it contains only FLASH addresses.

Why .vtable RAM section is added to the output file?
Is there a way to avoid this?
Should I leave the _FLASH pre-processor symbol and then copy the .vftable in RAM as I already do with the other .text and .const sections?


Thank you,
Carlo

  • Are you not using vtable at all? OR are you using the vtable but wondering why it is appearing in hex file? Note that RAM vector table is also defined in the CM interrupt driver. This enables registering interrupts at runtime. If you are not using registerHandler functions, vtable should not be included in the build at all

    Regards,

    Veena

  • Hello Veena,
    I use vtable and I register a couple of ISR:

    Interrupt_registerHandler(FAULT_NMI, NMIHandler)
    Interrupt_registerHandler(FAULT_SYSTICK, TickHandler)

    As the bootloader runs in RAM a have enabled the vectorTableRAM[] definition, by eliminating the _FLASH preprocessor symbol, and I have set the vector table address accordling:

    #ifdef _FLASH
    #pragma RETAIN(vectorTableFlash)
    #pragma DATA_ALIGN(vectorTableFlash, 1024U)
    #pragma DATA_SECTION(vectorTableFlash, ".vftable")
    void (* const vectorTableFlash[])(void) =
    #else
    #pragma RETAIN(vectorTableRAM)
    #pragma DATA_ALIGN(vectorTableRAM, 1024U)
    #pragma DATA_SECTION(vectorTableRAM, ".vtable")
    void (* const vectorTableRAM[])(void) =
    #endif
    {
    ...
    }

    Interrupt_setVectorTableOffset((uint32_t) vectorTableRAM)

    I am wondering why .vtable appears in the HEX file, as it resides in RAM.
    Isn't it useless, since it is not programmed in FLASH?

    Further more, how vectorTableRAM is initialized?
    For other .text and .const sections I perform an explicit copy form FLASH to RAM.

    .TI.ramfunc : {
        aaa.obj(.text)
        bbb.obj(.text)
        bbb.obj(.const)
        ...
    } LOAD = CMBANK0_SECTOR0,
      RUN = E0RAM,
      LOAD_START(RamfuncsLoadStart),
      LOAD_SIZE(RamfuncsLoadSize),
      LOAD_END(RamfuncsLoadEnd),
      RUN_START(RamfuncsRunStart),
      RUN_SIZE(RamfuncsRunSize),
      RUN_END(RamfuncsRunEnd),
      ALIGN(16)

    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t) &RamfuncsLoadSize);

    Regards,
    Carlo

  • Even though the vtable section is in the RAM section, the initial values should be stored in flash. This is copied to the RAM by the _c_int00 function.

    For example, below is the .map file output for a CM example from C2000ware -

    .vtable: load addr=00201690, load size=00000008 bytes, run addr=20000800, run size=00000140 bytes, compression=zero_init

    As you can see the vectorTableRAM array allocated in RAM at address 20000800. But the load address (where initial values are stored) is part of Flash memory.

    Regards,

    Veena

  • Hello Veena,
    looking at my map file I cannot find a .vtable section entry with load form flash / run form ram addresses, as the your one.

    The problem seems to be due in having deleted the _FLASH preprocessor symbol form the project.
    Restoring this symbol, indeed, the map file contains:
    - both .vftable and .vtable sections, and not only .vtable.
    - a .vtable entry with load from flash / run from ram addresses, as the your one.

    In .vftable section is allocated vectorTableFlash[] and in .vtable is allocated vectorTableRAM[].
    I have seen that vectorTableFlash[] is defined in startup_cm.c file, while vectorTableRAM[] is defined in the interrupt.c file of driverlib_cm library.

    Which is the relation between vectorTableFlash[] and vectorTableRAM[]?
    When is used the first and when the second one?
    I need that at runtime, after initialization phase, the bootloader runs entirely in RAM and so that vectorTableRAM[] is used.

    Moreover, after having restored the _FLASH preprocessor symbol, should I continue to set vector table address in RAM, with the following instruction, during initialization phase?

    Interrupt_setVectorTableOffset((uint32_t) vectorTableRAM)

    It seems it is useless, because it is implicity done in the Interrupt_registerHandler() function, that I use to register a couple of ISR:

    void
    Interrupt_registerHandler(uint32_t interruptNum, void (*intHandler)(void))
    {
    uint32_t index, value;

    ...

    //
    // See if the RAM vector table has been initialized.
    //
    if(HWREG(NVIC_BASE + NVIC_O_VTOR) != (uint32_t)vectorTableRAM)
    {
    //
    // Copy the vector table from the beginning of FLASH to the RAM vector
    // table.
    //
    value = HWREG(NVIC_BASE + NVIC_O_VTOR);
    for(index = 0U; index < NUM_INTERRUPTS; index++)
    {
    vectorTableRAM[index] = (void (*)(void))HWREG((index * 4U) + value);
    }

    //
    // Point the NVIC at the RAM vector table.
    //
    HWREG(NVIC_BASE + NVIC_O_VTOR) = (uint32_t)vectorTableRAM;
    }

    //
    // Save the interrupt handler.
    //
    vectorTableRAM[interruptNum] = intHandler;
    }

    Regards,
    Carlo