Relocating code for bootloader on MPC5643L

cancel
Showing results for 
Search instead for 
Did you mean: 

Relocating code for bootloader on MPC5643L

717 Views
Contributor I

Hello,

 

maybe someone can help with this this issue.

I am implementing a bootloader for MPC5643L. I am using CodeWarrior 10.5.

I've already tried a lot of solutions from this forum and the great search engine but it always throws me an linker error.

 

I implemented the code as follows:

__declspec(section ".init") extern void __startup(int argc, char **argv, char **envp);  #pragma section code_type ".bootvector" data_mode=far_abs __declspec(section ".bootvector") __asm void jumpToStartup(void);  __asm void jumpToStartup(void) {     b __startup; }   

 

Then I added the following line into the MEMORY block:

bootvector: org = 0x40004, len = 0x8 

 

And I added the following code to the SECTIONS block:

GROUP : {         .bootvector : {}     } > bootvector 

 

I also tried the upper statement without the GROUP definition - same result.

 

When I try to compile it I always get the linker error:

Linker command file output section '.bootvector' has a type or input which is incompatible with section '.bootvector' in file 'Boot_c.obj'. Change the type or add an input for this section.

 

What I am doing wrong here ?

 

Thank you,

Markus

Labels (1)
0 Kudos
4 Replies

70 Views
NXP Employee
NXP Employee

Hi Markus,

I've checked with colleague and see below their comments.

++++++++++++++++++++

The space occupied by the RCHW and application start address should be aligned at 16 bytes boundary. 

You need to make bootvector section aligned at 16 bytes boundary.

++++++++++++++++++++

Regards

Pascal

0 Kudos

70 Views
Contributor I

Hello Pascal,

thank you for your response.

My bootloader progam doesn't use the BAM (and therefore the RCHW) to jump into my application.

But even if I relocate the section 'bootvector' to an 0x10 aligned address (e.g. 0x40000 or 0x40010) I get the following

Linker error: Linker command file output section '.bootvector' has a type or input which is incompatible with section '.bootvector' in file 'Boot_c.obj'. Change the type or add an input for this section.

My bootloader works as follows:

  • bootloader is programmed (via JTAG programmer) to the target - the bootloader uses the BAM to boot and already works
  • the bootloader checks, if there is an valid application in an defined application flash memory area and tries to jump to the application entry point if there is an valid application

So I try to implement a branch instruction at address 0x40004 which points to the start of my application.

The bootloader uses a function pointer to jump to address 0x40004 and therefore should jump again to the start of my application.

Regards,

Markus

0 Kudos

70 Views
Contributor II

Hi Markus,

You can change your code as follows to avoid that error:

1. define the application function pointer

typedef void (*funcptr)(void);

#pragma push /* Save the current state */

#pragma section sconst_type ".__bootvectorarea"

const funcptr my_application = __startup;

#pragma pop


2. add items to linker command file


bootvector:  org = 0x00040000    len = 0x10


.__bootvectorarea LOAD(ADDR(bootvector)): {} > bootvector

FORCEACTIVE { "my_application"}


Regards,

Kevin


70 Views
Contributor I

Hello,

not exactly what I'm looking for but I'll give it a try - thanks.

My bootloader already uses a function pointer to jump to the start of the application (currently 0x40004 resp. 0x40010) so it would be nice if either the start of the application or a branch instruction to the start of the application would be located at this address.

With the solution above I now have a function pointer to a function pointer.

It's a common question for me how to locate a function to a designated memory address without this linker error.

0 Kudos