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.

Rm46 bootloader self update

Other Parts Discussed in Thread: RM46L852

Hi there,

I have a bootloader for rm46l852 up and running. It's using SCI Interface to download the firmware and FAPI 2.01.01 to program the firmware into flash.

I currently use the link.cmd file and the "_copyAPI2RAM_" function from the TI sample bootloader to move the FAPI code from the flash address range to the RAM address range, as this is required by the FAPI.

Now I would like to add self update functionality to the bootloader. My understanding is that I would need to move the whole bootloader code from Flash address range to RAM address range, not only the FAPI code. Then the bootloader could safely update itself in the Flash.

Is this correct and if so, could you please help me to lay out the Memory map for the bootloader to accomplish that magic?

Thanks a lot.

Johannes

  • The linker command file currently looks like this:

    --retain="*(.intvecs)"

    MEMORY
    {
    VECTORS (X) : origin=0x00000000 length=0x00000020
    FLASH_API (RX) : origin=0x00000020 length=0x000024E0
    FLASH0 (RX) : origin=0x00002500 length=0x002FEB00 //LS31x and RM48 Flash size is 0x300000
    SRAM (RW) : origin=0x08002000 length=0x0002D000
    STACK (RW) : origin=0x08000000 length=0x00002000
    }

    SECTIONS
    {
    .intvecs : {} > VECTORS
    flashAPI :
    {
    ..\Release\F021_API\Fapi_UserDefinedFunctions.obj (.text)
    ..\Release\bl_flash.obj (.text)

    --library= F021_API_CortexR4_LE_V3D16.lib < FlashStateMachine.IssueFsmCommand.obj
    FlashStateMachine.SetActiveBank.obj
    FlashStateMachine.InitializeFlashBanks.obj
    FlashStateMachine.EnableMainSectors.obj
    FlashStateMachine.IssueFsmCommand.obj
    FlashStateMachine.ScaleFclk.obj
    Init.obj
    Utilities.CalculateEcc.obj
    Utilities.WaitDelay.obj
    Utilities.CalculateFletcher.obj
    Read.MarginByByte.obj
    Read.Common.obj
    Read.FlushPipeline.obj
    Read.WdService.obj
    Async.WithAddress.obj
    Program.obj > (.text)
    } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)

    .text > FLASH0
    .const > FLASH0
    .cinit > FLASH0
    .pinit > FLASH0
    .data > SRAM
    .bss > SRAM
    }

    The "_copyAPI2RAM_" function Looks like this:

    ;-------------------------------------------------------------------------------
    ;
    ; Copy the Flash API from flash to SRAM.
    ;

    .def _copyAPI2RAM_
    .asmfunc

    _copyAPI2RAM_

    .ref api_load
    flash_load .word api_load
    .ref api_run
    flash_run .word api_run
    .ref api_size
    flash_size .word api_size

    ldr r0, flash_load
    ldr r1, flash_run
    ldr r2, flash_size
    add r2, r1, r2
    copy_loop1:
    ldr r3, [r0], #4
    str r3, [r1], #4
    cmp r1, r2
    blt copy_loop1
    bx lr

    .endasmfunc
  • Johannes,

    I personally do not like this idea. If something fails in updating the bootloader, your system will not able to restart and you will have to reprogram the unit via JTAG.

    I do not think that you can put the "whole" bootloader into RAM because CPU has to start from Flash. But you can add more bootloader functions to the API section in RAM so that no code will be executed from flash during bootloading (boolader top level control, SCI communication, and Flash erase/programming).

    Thanks and regards,

    Zhaohong
  • Yes, I agree. Thanks a lot.

    Johannes