Extracting ResetISR address from bin file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extracting ResetISR address from bin file

Jump to solution
1,778 Views
jeffthompson
Contributor V

I'm working with the MIMXRT1062, MCUXpresso IDE 11.1.0, and MXUXpresso SDK 2.6.2. My code is running out of external flash located at 0x600000000. I see that .text starts at 0x60002000 with g_pfnVectors (a.k.a. __Vectors), so the ResetISR address must be located at 0x60002004. From the .map filer, ResetISR is located at 0x6000231c, but using the memory browser, 0x60002004 contains 0x6000231d. This doesn't make sense to me because 0x6000231d is an odd address and off by 1 from the address of ResetISR. How do I correctly ascertain the ResetISR from the .bin file? I want to download a .bin file and run it, not as the boot image, but as a separate application image.

Labels (1)
Tags (1)
1 Solution
1,639 Views
mjbcswitzerland
Specialist V

Jeff

In the uTasker project we do it like this (passing a pointer to the location of the reset vector):

static void jump_to_application(unsigned long app_link_location)
{
     // Cortex-M3/M4/M7 assembler code
    //
    asm(" ldr sp, [r0,#0]"); // load the stack pointer value from the program's reset vector
    asm(" ldr pc, [r0,#4]"); // load the program counter value from the program's reset vector to cause operation to continue from there
}

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]

View solution in original post

3 Replies
1,639 Views
mjbcswitzerland
Specialist V

Jeff

The i.MX RT's Cortex-M7 uses ARM thumb mode where the odd address indicates that it is a thumb mode address - the address that is really used is with the LSB b1 of the address removed.

When jumping to code from programs the LSB b1 must also be set (even when the real address is even) in order to form a correct Thumb mode jump. If not done it is an ARM mode jump and will fail on the i.MX RT.

See also https://stackoverflow.com/questions/14120711/linux-kernel-why-a-functions-address-in-system-map-is-o...

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]

- https://www.utasker.com/iMX/RT1060.html

1,639 Views
jeffthompson
Contributor V

Mark, Thanks for the info and the link! I'm glad to see I'm not the only one who get confused.

So, I now have a function pointer set to the value of ResetISR, as found in the interrupt vector table, and I see that my code steps in ResetISR. In order to jump to my downloaded application code, it seems I also need to initialize the stack pointer, also found at the start of the table that contains the interrupt vectors. Is there anything else I need to do in order to get my downloaded application to run?

0 Kudos
Reply
1,640 Views
mjbcswitzerland
Specialist V

Jeff

In the uTasker project we do it like this (passing a pointer to the location of the reset vector):

static void jump_to_application(unsigned long app_link_location)
{
     // Cortex-M3/M4/M7 assembler code
    //
    asm(" ldr sp, [r0,#0]"); // load the stack pointer value from the program's reset vector
    asm(" ldr pc, [r0,#4]"); // load the program counter value from the program's reset vector to cause operation to continue from there
}

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]