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.

TM4C bootloader using bl_startup_rvmdk.s

Hello,

I am working on a custom bootloader using KEIL for TM4C, so my start up is bl_startup_rvmdk.s. My bootloader is to do some checks, and then jump to 0x8000 in flash where the main application locates. 

However I cannot jump to 0x8000, so to debug this, I take out all the checks, put only the jump in the BL_HW_INIT_FN_HOOK function hook, and the jump function is:

__asm void jump_to_application(void)
{
; program stack pointer of application
LDR R0, =0x8000
LDR SP, [R0]

; extract entry point into application
LDR R0, =0x8004

; jump
LDR PC, [R0]
}

and my BL_HW_INIT_FN_HOOK function, which is MyHwInitFunc is:

void MyHwInitFunc()
{

IntMasterDisable( );

jump_to_application();

}

I try the jump_to_application to other projects with other standard start up assembly, they all can jump to 0x8000, only except this bl_startup_rvmdk.S, any possible reason?

Thank you very much.

Khaled

  • Hello Khaled,

    I actually use on TivaWare's existing application codes to jump from boot loader to another application. See code below.

    void
    CallApplication(uint_fast32_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");
    }


    Regards

    Amit

  • Thanks Amit, I tried to call CallApplication function in MyHwInitFunc(), and put the code of CallApplication() in the same C file of MyHwInitFunc(), but Keil cannot compile CallApplication().

    It says:

    bl_hw_init.c(795): warning: #1267-D: Implicit physical register R1 should be defined as a variable
    " mov SP, R1\n");
    bl_hw_init.c(795): warning: #1267-D: Implicit physical register R0 should be defined as a variable
    " mov SP, R1\n");
    bl_hw_init.c(795): error: #549: variable "R0" is used before its value is set
    " mov SP, R1\n");
    bl_hw_init.c(795): error: #20: identifier "SP" is undefined
    " mov SP, R1\n");
    bl_hw_init.c(802): error: #1084: This instruction not permitted in inline assembler
    " bx R0\n");

    Do I need to include other code to make it compile? Thank you very much.

    Khaled

  • Hello Khaled,

    Please note that CallApplication needs a parameter of address. Is that being parsed by MyHwInitFunc?

    The manner in which Keil and CCS assmebly function calls are done, are slightly different so you may need to take that in account. If you can send the section of code, I can try it in Keil as well.

    Regards

    Amit

  • Thank you Amit for answering my questions. I managed to compile similar piece of assembly:

    CallApplication(uint_fast32_t ui32StartAddr)
    {

     //
     // Set the vector table to the beginning of the app in flash.
     //
     HWREG(NVIC_VTABLE) = ui32StartAddr;
    //{
    // ; program stack pointer of application
    ldr r1, [r0]
    mov sp, r1

    // ; extract entry point into application
    ldr r0, [r0, #4]

    // ; jump
    bx r0
    }

    After I step in and debug it did run the assembly code, but the main application which the bootloader should jump to does not run properly ( I set the LED to blink for main application, but I did not see the blink).

    Is there a way to debug if the jump is correct or to debug what happened after jump? Thank you very much!

    Khaled

  • Hello Khaled,

    Can you check if 0x8000 and 0x8004 contain valid SP and PC locations? It may be possible that when you loaded the Boot Loader code at 0x0 it may have erased the application code. A check of the same would be useful.

    Also what does the Cortex Register read in the debugger?

    Regards

    Amit

  • Hello Amit:

    I just checked at 0x8000, it is SP, and at 0x8004, it is pointing the main (different than PC). Is it correct? Thank you very much.

    Khaled

  • Hello Khaled,

    It is a little tough without the project code you have, to see where it is going wrong. I can try using the binary file (if you can share them) along with details on

    1. Which board EK/DK to use

    2. What is the location of each of the binaries

    In the meantime can you check if there is not fault condition being created by checking the NVIC_FAULTSTA and NVIC_FAULTADDR registers?

    Regards

    Amit

  • Thank you Amit, I uploaded both bins, and I'm using a tm4c129 dk. 

    3386.bootloader_0x0.zip

    2248.MainApplication_0x8000.zip

    In my main application, at address of NVIC_FAULTSTAT it is 0, and at address NVIC_FAULTADDR it is reset_handler. But I am not sure is it mean there is fault condition.

     

    Khaled

  • I just found out if at 0xE000ED28 it is 0, then it means there is no  fault condition, so I guess the main application does not have fault condition.

  • Hello Khaled,

    Would need a day or two to run this code on my DK board and see what is happening

    Regards

    Amit

  • Hello Amit,

    Thank you very much!

    Khaled

  • Hello Khaled,

    Were you able to resolve this issue? If not, can you please share your source code along with project files (for both bootloader and the application code). The one you shared previously, just had the binary files. Also let us know what interface the bootloader uses to load the application.

    Unless you have some specific needs (from the bootloader), the ROM bootloader can be used to program applications. Please refer the document SW-TM4C-BOOTLDR-UG for more details on the ROM bootloader.

    Thanks,
    Sai
  • Sai,

    The problem is not resolved yet, and yes, we have specific needs from the boot loader mainly loading a C6472 DSP ship that is connect to the EPI port.

    I'm in the middle of another project. I plan to finish it by the end of this week. By early next week, I should be able to give you the source code.

    thanks.

    Khaled.

  • Sai,

    I removed as much of the un-needed code but still there is a large section of proprietary code that I don't want to post on the web.

    Is there a secure place that I can use to copy those files to and that only TI has access to?

    Khaled.