Why does init section change size [MPC560*b]

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

Why does init section change size [MPC560*b]

844 Views
freakyfreak
Contributor II

Hello,

 

On some occasions the layout (size) of the init section changes. This is an issue to me because I need the "_startup" to be at a constant address.

Basically, my bootloader jumps to that area where the application is located.

 

On my other projects, the size of init section never change. Just having some trouble with this current project. And diffing between linker files and such shows that there are no differences.

Thus I need some guidance of why this is happening.

 

For instance, this is how the section in the map file should look like:

 

.__bam_bootarea section layout

  Starting        Virtual  File

  address  Size   address  offset

  ---------------------------------

  00000000 000008 00008000 00000320  1 .__bam_bootarea MPC5602B_init_flash_c.obj

  00000000 000004 00008000 00000320  4 bam_rchw MPC5602B_init_flash_c.obj

  00000004 000004 00008004 00000324  4 bam_resetvector MPC5602B_init_flash_c.obj

 

.init section layout

  Starting        Virtual  File

  address  Size   address  offset

  ---------------------------------

  00000000 0000a4 00008008 00000328  1 .init Linker Generated Symbol File

  00000000 000084 00008008 00000328  4 _rom_copy_info Linker Generated Symbol File

  00000084 000020 0000808c 000003ac  4 _bss_init_info Linker Generated Symbol File

 

And not like this:

 

.__bam_bootarea section layout

  Starting        Virtual  File

  address  Size   address  offset

  ---------------------------------

  00000000 000008 00008000 000002e0  1 .__bam_bootarea MPC5602B_init_flash_c.obj

  00000000 000004 00008000 000002e0  4 bam_rchw MPC5602B_init_flash_c.obj

  00000004 000004 00008004 000002e4  4 bam_resetvector MPC5602B_init_flash_c.obj

 

.init section layout

  Starting        Virtual  File

  address  Size   address  offset

  ---------------------------------

  00000000 000098 00008008 000002e8  1 .init Linker Generated Symbol File

  00000000 000078 00008008 000002e8  4 _rom_copy_info Linker Generated Symbol File

  00000078 000020 00008080 00000360  4 _bss_init_info Linker Generated Symbol File

 

 

Thank you!

Labels (1)
0 Kudos
4 Replies

546 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

there are two options:

1. Do not jump to constant address. Use the reset vector which is always on constant address and jump to address which the reset vector contains. This is the easiest way.

2. Modify the linker file, so the entry point is at the begging of a flash segment. I described something similar here:

Re: Boot Assist Module (BAM) with FlexCAN MPC5604P

See the "How to create RAM image". It is not exactly the same what you need but it should provide enough information what to do.

Regards,

Lukas

0 Kudos

546 Views
freakyfreak
Contributor II

Thank you sir for the support.

Seems like I will combine both options. I will offset the reset vector so that it's located on an address where the bootloader jumps to.

By changing some values in the linker and values regarding ROM image I can generate the expected map file.

However, I have some issues with "exception_handlers". Some how it is not jumping to the correct handlers. It is jumping to the old location, which now is all empty, due to offset.

Do you need to modify something else regarding "exception_handlers"?

Cheers!

0 Kudos

546 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Is the exception_handlers segment aligned to 4KB boundary? This could be the reason.

Lukas

0 Kudos

546 Views
freakyfreak
Contributor II

That's correct sir. That solved the issue.

00000004 000004 000080ec 00000324  4 bam_resetvectorMPC5604B_init_flash_c.obj

Following the first option, the above address is where I should jump to from the boot-loader.

Sadly, that is not working properly. By single stepping I can notice that it ends up in the .init sections in the boot-loader.

The first memory "bank" is used for boot-loader, the second one is for the application.

Lets try option two instead. Re-arrenging the entry point.

Before:

GROUP : {

    /* Section used for initialization code: __ppc_eabi_init.c,

     MPC56xx_HWInit.c, MPC56xx_init_*.c and the entry point (__startup).

     */

      .init LOAD(ADDR(init)) : {}

      .init_vle (VLECODE) LOAD(_e_init) : {

        *(.init)

        *(.init_vle)

      }

    } > init


After:

    GROUP : {

    /* Section used for initialization code: __ppc_eabi_init.c,

     MPC56xx_HWInit.c, MPC56xx_init_*.c and the entry point (__startup).

     */

     

      .init_vle (VLECODE) LOAD(ADDR(init)) : {

        *(.init)

        *(.init_vle)

      }

      .init LOAD(_e_init) : {}

    } > init

Generates no warnings or errors.

MAP file seems to be fine.

Ends up stuck in there. Any idea?

4 ivor_branch_table_p0() ivor_branch_table.c:40 0x00009020
3 __copy_rom_section() __start.c:271 0x000080b0
2 __init_data() __start.c:357 0x00008116
1 __start() __start.c:213 0x0000806a

Yours,

He

0 Kudos