problem while I build, bootloader for Kinetis K60

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

problem while I build, bootloader for Kinetis K60

1,878 Views
ahergonb
Contributor I

Hello, I have a problem when building the project bootloader from the downloadable document an2295sw. Within the src where are the source code, the module bootloader.c. send me 3 errors in the following function:

void JumpToUserApplication(LWord userSP, LWord userStartup)

{

  // set up stack pointer

  __asm("msr msp, r0");

  __asm("msr psp, r0");

  // Jump to PC (r1)

  __asm("mov pc, r1");

}

The error that occurs is as follows:  

{(assembler source):1}   msr msp, r0

  undefined identifier 'r0',

undefined identifier 'r0',

{(assembler source):1}   msr msp, r1

undefined identifier 'r1'

I guess it's because r0 and r1 are not native registers within the microcontroller.

Any help or ideas is much appreciated.

Labels (1)
0 Kudos
12 Replies

762 Views
ahergonb
Contributor I

I installed the CodeWarrior 10.3 and the problem I had in JumpToUserApplication function (); already solved, now the problem is, within the bootloader.c on line 117 I have the following error:

  missing braces around initializer [-Wmissing-braces] (near initialization for 'bootloaderIdent.blockDesc [0]') [-Wmissing-braces]

the structure:

BootloaderIdentOptimType const bootloaderIdent

in line {LITTLE2BIG (USER_FLASH_START) LITTLE2BIG (USER_FLASH_END)},

also provides that:

./Sources/bootloader_c.obj:(.IntVectTable+0x0): undefined reference to `__BOOT_STACK_ADDRESS'

0 Kudos

762 Views
pavel_krenek
NXP Employee
NXP Employee

Hi Alejandro,

what version of the bootloader are you using ? Could you try check the revision of the AN2295.

Have you tried you the compilation for IAR 6.4 ?

Best regards,

Pavel

0 Kudos

762 Views
albertolubeiro
Contributor III

HI  I have the K60 and using the following code of AN2295 can´t jump to the desired address. Any idea?

static void JumpToUserApplication(LWord userStartup)

{

    /* set up stack pointer */

    asm("LDR      r13, [r0]");

    /* jump to application reset vector */

    asm("ADD      r0,r0,#0x04 ");

    asm("LDR      r0, [r0]");

    asm("BX       r0");

}

It jumps to another address and not to where i want.

I am using CW 10.2

Thanks and best regards

0 Kudos

762 Views
pavel_krenek
NXP Employee
NXP Employee

Hi Alberto,

on the webpages is new version of the AN2295. It will be better if you begin use this one and we can be synchronized.

Pavel

0 Kudos

762 Views
albertolubeiro
Contributor III

Hi Pavel

Yeah, i have just downloaded the last version of AN2295 but still can't do a jump to my app.

In order to check if the code is ok, i have place a function to an address and have tried to do the jump to this function. The jump went ok, so i don't know where the broblem can be when i try to jump to my app.

At this moment the boot is just a basic proyect. It only configures the micro and in main function makes a jump to the entry point of the application.

The address i want to jump to, is 0x4800 that is the origen of application's m_text segment.

APPLICATION

m_text        (RX) : ORIGIN = 0x00004800, LENGTH = 0x00040000-0x00004800


I have made a silly probe. I have loaded only the application and put a break point into the start of "__thumb_startup" function in order to see the vaule of PC.

Then i have loaded also the boot, making the jump to the address of "__thumb_startup" watching before.

This way, it results that the jump to my application is made fine but is not supposed that the address to wich i have to jump should be 0x4800?


Thanks


Alberto

0 Kudos

762 Views
albertolubeiro
Contributor III

Hi Pavel,

The problem is solved.

The startup code doesn't have to be placed at begining of the m_text segment, so the solution is to place the startup function into a fixed address and jump always to this address.

Thanks

Best regards

0 Kudos

762 Views
UK_CF_FAE
NXP Employee
NXP Employee

Hi Alejandro,

I'm running the code from AN2295 in both IAR, and I'm porting it to GCC compiler in CodeWarrior 10.3 at the moment. I have no problems compiling it in EWARM 6.50.3, and it compiles and runs in CW10.3 (just a bit of cleaning up to do).

What toolchain are you using?

Kinetis K-series has CM4 core, with 16-off 32-bit registers, and R0, R1 are certainly part of the core. You will find that the functioncall JumpToUserApplication will load the userSP and userStartup in R0 and R1 when the function is called - this is the default behaviour when a C function is called with two unsigned int parameters.

There are many ways to insert assembler code into a C project. you can try

asm ("msr msp, r0") instead of the __asm

Sometimes the toolchain is case sensitive, but both my EWARM and CW10.3 are not.

Mark

0 Kudos

762 Views
ahergonb
Contributor I

Hi Mark,

I'm using the CodeWarrior 10.1 and IAR in version 6.3, i'm not sure if this could be the problem

0 Kudos

762 Views
pavel_krenek
NXP Employee
NXP Employee

Hi Alejandro,

First of all I recommend to you using  IAR in version 6.4 and also CodeWarrior 10.3. Your explanations look as the bug is in the configuration of the bootloader.

What MCU do you use ?

AN2295 Developer

Pavel Krenek

0 Kudos

762 Views
ahergonb
Contributor I

Hi Mark,

I'm using the MK60DN512Z

0 Kudos

762 Views
pavel_krenek
NXP Employee
NXP Employee

If you are using CW should be used function:

#elif defined(__CWCC__)

asm void JumpToUserApplication(LWord userSP, LWord userStartup)

{

  // set up stack pointer

  msr msp, r0;

  msr psp, r0;

  // Jump to PC (r1)

  mov pc, r1;

}

#endif

or if you are using IAR or uVision should be use this function for jumping to application:

#if defined(__IAR_SYSTEMS_ICC__) || defined(__ARMCC_VERSION)

void JumpToUserApplication(LWord userSP, LWord userStartup)

{

  // set up stack pointer

  __asm("msr msp, r0");

  __asm("msr psp, r0");

  // Jump to PC (r1)

  __asm("mov pc, r1");

}

Could you try to check if is the correct function is compiled.

Pavel

0 Kudos

762 Views
ahergonb
Contributor I

I tried that, but the same error still appears, maybe I'm wrong in using the # if defined (__ARMCC_VERSION) or __ attribute__ ((section (". FlashConfig"))) const FlashConfig_t Config __ attribute__ ((used)) within the bootloader.c

Or my mistake either in some # if defined, the problem is I don't know much of the CodeWarrior compiler directives.

Maybe I'm wrong in a. h

can you help me on that please?

0 Kudos