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.

How to jump to a flash meory location using asm inline statement for TMC4129DNPDT board

Other Parts Discussed in Thread: TM4C129DNCPDT

Hi,

I have my executable image stored at an internal flash memory location of TM4C129DNCPDT. I want to jump to that memory location from my c program using asm inline statement. But what i found is that there is no "JMP" instrution in the instruction set of TM4C129DNCPDT. I am using it like below:

asm(" jmp 0x1234") where 0x1234 is the flash memory location where i want to jump and start executing the code present there.

How to achieve this? Is there any other optional instruction present instead of JMP?

Thanks in Advance.

Regards,

Shrikant

 

  • Hello Shrikant

    You can refer to the following thread

    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/321081/1122066.aspx#1122066

    Regards

    Amit

  • Hi Amit,

    Thanks for your reply on this. By following the link you have shared i tried using below thing to JUMP on to the desired flash memory location on TM4C129DNCPDT :

    // Set the vector table to the beginning of the app in flash.
        HWREG(NVIC_VTABLE) = 0x1000;

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

        // 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"); 

    But while debugging i found that there is some issue with the last command. It gives me below error when i try to execute line " __asm("    ldr     r0, [r0, #4]\n"
              "    bx      r0\n"); "

     

    Here is the errror that i get:

    Can't find a source file at "/tmp/TI_MKLIBBMPOk8/SRC/memcpy_t2.asm"
    Locate the file or edit the source lookup path to include its location.

    I have also verified if the address 0x1000 of flash memory has my executable code or not. So that's not the issue.

    Can you please verify and let me know if it really works for TM4C129DNCPDT board. Is there any change required.

    I have tried it multiple times but still facing the same error.

     

  • Hello Shrikant,

    It looks to be that the intermediate temp file is missing. The main question is that does it jump to the location you expect it to?

    Regards

    Amit

  • Hi Amit,

    As an answer to your question, it doesn't jumps to the location i am trying it to go and execute binary present at that location.

    I am also not getting of which intermediate file you are trying to mention.

     

  • Hello Shrikant

    OK. Let me check as well. Will post an update.

    Regards

    Amit

  • Hi Amit,

    Any updates on this?

  • Hi,

    From the debug errors i have mentioned, it seems to me that while trying to execute the assembly code it is searching for some source file like boot.asm and it is not getting that. But i am not sure.

    Help from an expert may be helpful to find solution quikly.

  • Hi,

    It is not quite clear your goals with this problem - either you try to make your own boot loader - and in this case the file Tiva/bootloader/bl_startup_ccs.c is a good starting point, no need to re-invent the wheel, either you try to re-start your application (without any boot loader), and in this case there are better solutions than just jumping.

    Petrei

  • Hi,

    Here is my goal to make it very clear to you : I am writing a boot image verfier program which will check the integrity of the image to boot and if the image has no problems it will jump to the start address of that image and boot from there. There can be more that one images present which is also handled by this program.

    This program will be present from the address 0x0 of my flash memory and will execute after the rom Bootloader code finishes execution. I didn't wanted to take this discussion to a different loop that's why i didn't mentioned in my earlier discussions.

    Now my question is very simple: Assume that i have done all  verfification and decided which image to boot. So how to start booting from the image i have decided to. Obviously we will have to jump to that location. I didn't find any "jmp" like instruction in the instruction set of TM4C129DNCPD, So used the inline assembly code mentioned above. But i am getting errors which i mentioned earlier while executing the inline assembly statements. Also it is not jumping to the image location i am trying it to jump and execute.

    I hope you undertand my goal and problem now.

     

     

  • Hi,

    I am disappointed you do not follow advices… Here are an excerpt from the mentioned file, showing how to jump to application start point (which will be similar to an application loaded from 0 - first set SP, then PC and then brand to new location):

    ;;
        ;; Set the application's vector table start address.  Typically this is the
        ;; application start address but in some cases an application may relocate
        ;; this so we can't assume that these two addresses are equal.
        ;;
        movw    r0, #(VTABLE_START_ADDRESS & 0xffff)
     .if (VTABLE_START_ADDRESS > 0xffff)
        movt    r0, #(VTABLE_START_ADDRESS >> 16)
     .endif
        movw    r1, #(NVIC_VTABLE & 0xffff)
        movt    r1, #(NVIC_VTABLE >> 16)
        str     r0, [r1]
    
        ;;
        ;; Load the stack pointer from the application's vector table.
        ;;
     .if (APP_START_ADDRESS != VTABLE_START_ADDRESS)
        movw    r0, #(APP_START_ADDRESS & 0xffff)
     .if (APP_START_ADDRESS > 0xffff)
        movt    r0, #(APP_START_ADDRESS >> 16)
     .endif
     .endif
        ldr     sp, [r0]
    
        ;;
        ;; Load the initial PC from the application's vector table and branch to
        ;; the application's entry point.
        ;;
        ldr     r0, [r0, #4]
        bx      r0

    The "jump" in ARM .asm is "bx" (branch). 

    Petrei

  • Hi,

    I have tried the above thing and i am getting an error. Here is my code snippet 

    int

    main(void)

    {

    //Set up needed modules

    se_my_modules();

    // Set the vector table to the beginning of the app in flash.

    HWREG(NVIC_VTABLE) = (uint32_t)0x2000;

    // Load the stack pointer from the application's vector table.

    __asm(" ldr r1, [r0]\n"

    " mov sp, r1");

    // 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");

     

    and I am getting an error like below:

    cant find a source file "tmp/......./boot.asm"

  • Hello All,

    Quite a few times this request has come up on the forum. So here it goes

    The first code called TM4C129_FlashBootStrap will look for an image at location 0x10000. if it is there then it will jump to it. If not then it will slow blink the led at rate of 1 blink per 2 seconds

    The second code TM4C129_StrapCode is another image which will blink the LED 4 times faster so that you know that code has successfully jumped.

    Do note that it is all JTAG Based code upload and used the DK-TM4C129 board, so any modifications as per the requirements on a custom board or an EK-TM4C129 may need to be done.

    3515.TM4C129_FlashBootStrap.7z

    0804.TM4C129_StrapCode.7z

    Regards

    Amit

  • Hi,

    I think you should not go more than one or two .asm instructions after bx, since your new application is not loaded into debugger, so you cannot debug further from that point.

    Petrei