MPC5554, Placing variables in external RAM

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MPC5554, Placing variables in external RAM

跳至解决方案
4,367 次查看
Oliv74
Contributor I

Hi,

During my experiments with the MPC5554EVB development board, I successfully initialized the external RAM (starting a 0x20000000).

 

But now I would like to force the linker to place some  variables in this external memory and to keep the other ones in the SRAM.

 

I tried to create new sections in my lcf file:

 

 

MEMORY{    pseudo_rom:         org = 0x40000000,   len = 0x00009000    init:               org = 0x40009000,   len = 0x00001000    exception_handlers: org = 0x4000A000,   len = 0x00001000    internal_ram:       org = 0x4000B000,   len = 0x00002000    heap  :             org = 0x4000D000,   len = 0x00001000    stack :             org = 0x4000E000,   len = 0x00001000     external_ram:       org = 0x20000000,   len = 0x00080000}SECTIONS{...GROUP : {       .ext_ram_text (TEXT) : {}       .ext_ram_data (DATA) : {}    } > external_ram}

 

and in my code I declare the variable that I want to place in external RAM like this:

 

 

 

#pragma section data_type ".ext_ram_data" __declspec(section ".ext_ram_data") uint8_t buffer[512];

 

 But I'm getting compilation errors...

 

 

Error   : sections used for data must have an uninitialized data sectionError   : unknown section name '.ext_ram_data'

 

Thanks in advance for your help,

 

Olivier

 

0 项奖励
回复
1 解答
2,827 次查看
CrasyCat
Specialist III

Hello

 

Can you try to modify the variable definition as follows:

 

#pragma section data_type ".ext_ram_data" ".ext_ram_data" __declspec(section ".ext_ram_data") uint8_t buffer[512];

 

 

The variable buffer is not initialized. So you need to specify a uname section in the pragma section.

See Power Architecture Build Tools Reference.pdfm chapter Pragmas for Power Architecture Compiler section Library and Linking Pragmas > section.

 

 

CrasyCat

在原帖中查看解决方案

0 项奖励
回复
9 回复数
2,826 次查看
wg0z
Contributor II

i'm new to the 5554 but i suspect the line that reads

  .ext_ram_data (DATA) : {}

needs to have information insides the braces.

 

this is toolset-dependet stuff, to some extent, i think.

tell us what you are using

0 项奖励
回复
2,828 次查看
CrasyCat
Specialist III

Hello

 

Can you try to modify the variable definition as follows:

 

#pragma section data_type ".ext_ram_data" ".ext_ram_data" __declspec(section ".ext_ram_data") uint8_t buffer[512];

 

 

The variable buffer is not initialized. So you need to specify a uname section in the pragma section.

See Power Architecture Build Tools Reference.pdfm chapter Pragmas for Power Architecture Compiler section Library and Linking Pragmas > section.

 

 

CrasyCat

0 项奖励
回复
2,827 次查看
sumanththallam
Contributor I

Hi i have tried using the below statements, compiler gives error

 

#pragma section TRYme ".tryme" ".tryme"  __declspec(section ".tryme") extern char OS_TrapHndl_TrapAddr;

 

the variable OS_TrapHndl_TrapAddr is declared in other source file.

 

i am using it in MPC5674,

 

The compiler error is " error (dcc:1633): parse error  near '".tryme"'"

 

can some one pls say if there are any settings needed for the __declspec to be made.

 

Thanks in advance.

 

Regards,

Sumanth

0 项奖励
回复
2,827 次查看
CrasyCat
Specialist III

Hello

 

Two issues here:

  1- The  __declspec should be specified in a new line (not on the same line as the pragma.

       Apparently Lithium did remove the line breaks in my original code snippet.

 

  2- The declspec should be done on both the variable definition and declaration,

 

CrasyCat

0 项奖励
回复
2,827 次查看
sumanththallam
Contributor I

Hello CrasyCat,

 

Thanks for the reply.

 

i have changed as follows in one file apart from the source file where OS_TrapHndl_TrapAddr; is declared(static UINT32 OS_TrapHndl_TrapAddr:smileywink:

 

xyz.c

#pragma section TRYme ".tryme" ".tryme"
__declspec(section ".tryme") extern UINT32OS_TrapHndl_TrapAddr;

 

the compiler issues the error message "error (dcc:1633): parse error  near '".tryme"'"   refers to (section ".tryme")

 

i am trying to move the variables declared in other source files to a new section(without touching the source code). my approach is correct or is there any other way of doing it.

 

Thanks & Regards,

Sumanth

 

0 项奖励
回复
2,827 次查看
CrasyCat
Specialist III

Hello

 

  First parameter in pragma section identifies the type of object stored in the section.

 

TRYMe is not a valid object type.

 

Did you try:

 

  #pragma section data_type".tryme" ".tryme" 
  __declspec(section ".tryme") extern UINT32OS_TrapHndl_TrapAddr;

 

CrasyCat

0 项奖励
回复
2,827 次查看
sumanththallam
Contributor I

Hello ,

 

i have also tried the statements u sent. the error still occurs at 2 line that is " __declspec(section ".tryme") extern UINT32OS_TrapHndl_TrapAddr"  

 

error is : parse error  near '".tryme"'

 

i am not using code warrior, i am using Tasking EDE with wind river DIab compiler 5.8.0.0

 

the user manual for the diab compiler doesnot contain the __declspec, pls confirm whether the __declspec would work in this environment.

 

pls also confirm that without modifying the .c file, if it would be possible to move variables to new section.

0 项奖励
回复
2,827 次查看
CrasyCat
Specialist III

Hello

 

The notation __declspec(section ".tryme") extern UINT32OS_TrapHndl_TrapAddr is only working with CodeWarrior compilers.

 

If you are using another compiler, please check with the compiler provider how you can define variables in a user defined section.

 

CrasyCat

0 项奖励
回复
2,827 次查看
Oliv74
Contributor I

Hello,

 

Thanks a lot for your response!

Now the variable "buffer" is correctly placed in the external RAM.

 

Olivier

0 项奖励
回复