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.

Tivaware bootloader run command and how to CallApplication

Hi all,
I use raspberry pi as a host to communicate with TM4C123gxl via UART. I want to demo a flash bootloader feature.
After weeks of work and the help form TI community ,I can use every command packets of tivaware bootloader except "Run command ". I have checked that after recieving  run command,the program is in the "case COMMAND_RUN:"and the program run till "Reset and disable the peripherals used by the boot loader ".
I guess that

((void (*)(void))g_ui32TransferAddress)();

doesn't work. After searching the Forum, I found some articles about CallApplication.
So I use a function to instead  ((void (*)(void))g_ui32TransferAddress)(). The Function is :

void
CallApplication(uint32_t ui32StartAddr)
{
    //
    // Set the vector table to the beginning of the app in flash.
    //
    HWREG(NVIC_VTABLE) = ui32StartAddr;

    //
    // Load the stack pointer from the application's vector table.
    //
    __asm("    ldr     r1, [r0]\n"
          "    mov     sp, r1\n");

    //
    // Load the initial PC from the application's vector table and branch to
    // the application's entry point.
    //
    __asm("    ldr     r0, [r0, #4]\n"
          "    bx      r0\n");
}

After adding this to the project and building it with CCS, I can send a run command to bootloader and the application will run.
My question is as below :

does "((void (*)(void))g_ui32TransferAddress)();" really not work or I missed something?
how can I write a CallApplication in Keil? I studied many forum about " Keil : Inline assembly in C ",but still didn't figure out.

Appreciate for any help.

  • Hello Yen,

    Is g_ui32TransferAddress the start of the Vector Table or the address of the ResetISR? Reading the post it looks like g_ui32TransferAddress is the start of the Vector Table. In which case, the call  "((void (*)(void))g_ui32TransferAddress)();" will not work and generate a fault, as there is no instruction to execute at that address.

    Keil should have documentation on how to write inline assembly code in C. Another approach that might also work is to create the CallApplication function in a dedicated assembly file and call this function from a C file.

    Hope this helps!

    Sai

  • This reporter suspects that, "Inline Assembly" IS well detailed w/in (one) of the many Keil information files. (I know that to be the case w/in IAR.)

    Sometimes - when "stuck" as you now appear - study/review of another "pro" IDE (not any vendor specific/limited one) may reveal a clearer, "method/madness" which may work much to your advantage...

    I'd read "Stellaris Sai's" answering post several times - I believe your focused study there - and at the simply terrific, "Boot-Loader Sticky" post (atop this forum) authored by Amit - will lead you to success...

    Poster Yen is skilled & thoughtful - yet even Yen provides NO supporting justification for this, "Rush to Boot-Load!"   Is there really a "need" for boot-load?   There's risk - is there not - and much extra time/effort required - and we've not one word of support for this (urgent) need!   (from poster Yen and (all) other boot-load obsessed - yet stuck - seekers...)