We are using the SPC5605B processor, which is supposed to have 64K of RAM.  For some reason my predecessor set up the linker command file for 32K.  When I change the lcf settings to 64K, the project builds but when run, the code goes out into the weeds an

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

We are using the SPC5605B processor, which is supposed to have 64K of RAM.  For some reason my predecessor set up the linker command file for 32K.  When I change the lcf settings to 64K, the project builds but when run, the code goes out into the weeds an

1,675 Views
ronjaeger
Contributor II

We are using the SPC5605B processor, which is supposed to have 64K of RAM.  For some reason my predecessor set up the linker command file for 32K.  When I change the lcf settings to 64K, the project builds but when run, the code goes out into the weeds and doesn't come back.  Is there anything else in the project that needs to be changed to use the whole 64K?

Labels (1)
12 Replies

1,544 Views
ronjaeger
Contributor II

That fixed it.

Thanks.

Ron

1,544 Views
ronjaeger
Contributor II

Thanks for replying, Martin.

The people who wrote this code are no longer here, and I'm not extremely familiar with PPC assembly.  From what I can tell, the intention is to load R11 with the value __SP_END (which is 4000FC00) with the instructions:

   e_lis         r11, __SP_END@ha        # low address of stack

   e_or2i      r11, __SP_END@l

But as you mentioned, after executing these lines, R11 contains 4001FC00 rather than 4000FC00.  Since there is no RAM there, the stack_loop crashes.

Immediately prior to these instructions, R11 contains 40010000 as a result of a previous loop.  It was obviously expected that the lines noted above would reset R11 to 4000FC00, but they don't.  I'm guessing this has something to do with sign extension or something, even though this is a load instruction, not an add instruction.  I don't quite understand why the load immediate doesn't set the upper address back to 4000.  Can you suggest the proper instructions to use here?

Thanks,

Ron

0 Kudos

1,544 Views
martin_kovar
NXP Employee
NXP Employee

Hi Ron,

I would like to correct my previous post a little bit. You can fill the stack memory from address 4000FC00 to 40010000. It is not necessary to access it from 40010000 downwards. It was my misunderstanding.

You only need to fix the following line:

e_lis      r11, __SP_END@ha

instead of this use only:

e_lis r11, __SP_END@h

Now it will work correct. You can check the address in r11 will be 4000FC00 now and you will be able to fill the stack with defined pattern DEADBEEF.

If you have any other question, please feel free to write me back.

Regards,

Martin

0 Kudos

1,544 Views
ronjaeger
Contributor II

OK, here's the project.  The 3 lines I changed in the lcf file are described in comments.  As I mentioned, the 32K settings run fine, the 64K settings won't run at all (debugger won't step off of the first line of crt0.s).

Regards,

Ron

0 Kudos

1,544 Views
martin_kovar
NXP Employee
NXP Employee

Hi Ron,

I think your problem is this part of code:

pastedImage_0.png

At first, you should have set stack pointer before you initialize SRAM. Second problem is value in register r11 where you want to store r10 register (instruction e_stw). The value in r11 is 4001FC00, but your stack starts at 40010000. You have to fill stack from the address 40010000 to address 0x4001FC00. Fix this stack_loop in sram_init.s file and it will work correct.

Regards,

Martin

0 Kudos

1,544 Views
ronjaeger
Contributor II

I don't have variable L2SRAM_CNT or module HWInit.c.  This code has crt0.s and init_sram.s, which use these symbols defined in the lcf:

__SRAM_BASE = 0x40000000;

__SRAM_SIZE = 0x10000;

__SP_INIT=ADDR(stack_ram)+SIZEOF(stack_ram);

__SP_END=ADDR(stack_ram);

__STACK_SIZE=SIZEOF(stack_ram);

__HEAP_END=__SP_END;

__FLASH_START_ADDRESS=ADDR(flash);

__FLASH_SIZE=SIZEOF(flash);

__RAM_START_ADDRESS=ADDR(sram);

__RAM_SIZE=SIZEOF(sram);

Ron

0 Kudos

1,544 Views
martin_kovar
NXP Employee
NXP Employee

Hi Ron,

Ok you have your own project structure, so it is a little bit difficult for me to provide you more information without deeper knowledge of your project. Could you please provide me some simple project, which demonstrates your issue?

Regards,

Martin

0 Kudos

1,544 Views
ronjaeger
Contributor II

I replied to your email with an attached small zipped-up project that demonstrates the problem.  If the settings in the lcf file are put back to the 32K settings, the code runs normally.  When built with the 64K settings, the code won’t run (the debugger won’t step off of the first line in crt0.s).

I didn't see a way to add an attachment here.  Let me know if you don't get the zipped file.

Ron

0 Kudos

1,544 Views
martin_kovar
NXP Employee
NXP Employee

Hi Ron,

I did not receive the project. If you want to add attachment, click reply, and choose Use advanced editor.

pastedImage_0.png

Now there is the option Attach.

pastedImage_1.png

Please share the project once again.

Regards,

Martin

0 Kudos

1,544 Views
ronjaeger
Contributor II

I replied to the email, but apparently that didn't get posted here.

We are using CodeWarrior V10.3.

Further info:

This is what I changed in the lcf.  The 32K settings work, but the 64K settings don't.

__SRAM_BASE = 0x40000000;
__SRAM_SIZE = 0x10000;

/* Changed from (32K):
__SRAM_SIZE = 0x8000;
*/
/* Changed to (64K):
__SRAM_SIZE = 0x01000;
*/

MEMORY
{
        bootloader:             org=0x00000000, len=0x00008000
        reserved:               org=0x00008000, len=0x00000000
        flash:                  org=0x00010000, len=0x000B0000
        data_flash:             org=0x00800000, len=0x00010000
        sram:                   org=0x40000000, len=0x0000FC00          
        stack_ram:              org=0x4000FC00, len=0x00000400
}
/* Changed from (32K):
        sram:                   org=0x40000000, len=0x00007C00          
        stack_ram:              org=0x40007C00, len=0x00000400
*/
/* Changed to (64K):
        sram:                   org=0x40000000, len=0x0000FC00          
        stack_ram:              org=0x4000FC00, len=0x00000400
*/

0 Kudos

1,544 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

have you correctly configured the following symbol in the linker file?

/* How many writes with stmw, 128 bytes each, are needed to cover

   the whole L2SRAM (used for L2 SRAM initialization) */

L2SRAM_CNT = 0x10000 / 128;

This symbol is used during startup (in HWInit.c file) and it ensures correct RAM initialization.

Regards,

Martin

0 Kudos

1,544 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

could you please clarify, which IDE you use?

Regards,

Martin

0 Kudos