Allocating in Flash [SOLVED]

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

Allocating in Flash [SOLVED]

Jump to solution
1,756 Views
Stevanatto
Contributor II

Hi, I have a CW 5.9.0 to compile PPC MPC5633M.

Some problem with fixed variable allocation. I have a program that run in RAM target but doesn't run in FLASH taget. What am I wrong ?

The code:

#pragma push #pragma section ".myFlash" ".myFlash" __declspec(section ".myFlash") const int var1[1]; #pragma pop  int main(void) {     int var2 = var1[0];     while(1); } 

In my .lcf  I inserted

my_flash: org = 0x00100000, len = 0x00080000 

and

GROUP : {     .myFlash : {} } > my_flash 

Then I get a exception while run the program and processor does not reach main() .

Labels (1)
Tags (2)
0 Kudos
Reply
1 Solution
1,523 Views
stanish
NXP Employee
NXP Employee

Hello Carlos,

This issue is probably related to .lcf file. I'd recommend you to add LOAD() command:

GROUP : {

    .myFlash LOAD (ADDR(my_flash)) : {}

} > my_flash

LOAD(ADDR(my_flash)) or LOAD (0x10000)  causes that .myFlash section will not create a separate image in ROM but the section starting address will be equal to ROM address = 0x00100000

If ROM address and section starting address are different then the default CodeWarrior startup routine performs copy the section block from ROM address to section starting address.

Since both addresses are in FLASH in your case an exception occurs.

You can  check the Start and ROM addresses in generated .map file, e.g.:

Memory map:

                       Starting Size     File     ROM      RAM Buffer  S-Record

                       address           Offset   Address  Address     Line

       .__bam_bootarea 00000000 00000008 000004c0 00000000 00000000          2

                 .init 00000020 000000f4 000004c8 00000020 00000020          3

             .init_vle 00000114 00000244 000005bc 00000114 00000114         16

  .__exception_handlers 00001000 000000a8 00000800 00001000 00001000         45

             .text_vle 00002000 00000394 000008b0 00002000 00002000         54

....

Hope it helps.

Stan

View solution in original post

0 Kudos
Reply
2 Replies
1,524 Views
stanish
NXP Employee
NXP Employee

Hello Carlos,

This issue is probably related to .lcf file. I'd recommend you to add LOAD() command:

GROUP : {

    .myFlash LOAD (ADDR(my_flash)) : {}

} > my_flash

LOAD(ADDR(my_flash)) or LOAD (0x10000)  causes that .myFlash section will not create a separate image in ROM but the section starting address will be equal to ROM address = 0x00100000

If ROM address and section starting address are different then the default CodeWarrior startup routine performs copy the section block from ROM address to section starting address.

Since both addresses are in FLASH in your case an exception occurs.

You can  check the Start and ROM addresses in generated .map file, e.g.:

Memory map:

                       Starting Size     File     ROM      RAM Buffer  S-Record

                       address           Offset   Address  Address     Line

       .__bam_bootarea 00000000 00000008 000004c0 00000000 00000000          2

                 .init 00000020 000000f4 000004c8 00000020 00000020          3

             .init_vle 00000114 00000244 000005bc 00000114 00000114         16

  .__exception_handlers 00001000 000000a8 00000800 00001000 00001000         45

             .text_vle 00002000 00000394 000008b0 00002000 00002000         54

....

Hope it helps.

Stan

0 Kudos
Reply
1,523 Views
Stevanatto
Contributor II

It works and I keep my memory map untouched:

MEMORY

{

    resetvector:           org = 0x00000000,   len = 0x00000008

    init:                   org = 0x00000020,   len = 0x00000FE0   

    exception_handlers:    org = 0x00001000,   len = 0x00001000

    internal_flash:        org = 0x00002000,   len = 0x000FE000 /*0x0017E000*/

    my_flash:              org = 0x00100000,   len = 0x00080000 /* 512K C2 Flash */

    internal_ram:          org = 0x40000000,   len = 0x00014000

    heap  :                org = 0x40014000,   len = 0x00002000

    stack :                org = 0x40016000,   len = 0x00001800

}

Thank you for your help.

0 Kudos
Reply