Defining memory segment in PRM file

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

Defining memory segment in PRM file

5,505 Views
Xbot
Contributor II
hi all,
 
I am defining labels inside the .prm file so i can use __SEG_START or END for a particular memory segment. Ive read tn2281 but it doesnt seem to work.
 
for instance:
 

SEGMENTS

      TESTMEM = READ_WRITE 0x140000 TO 0x77FFFF FILL 0x3F;

END

 

PLACEMENT

      TestMemory INTO TESTMEM;

END
 
usage:
 
extern char __SEG_START_TestMemory[];
#define TestMemoryStart __SEG_START_TestMemory
 
char* StartAddress = (char*)TestMemory;
 
I dont seem to get the value for StartAddress. Is there something I missed?
I am using EVB9S12XEP100 board , CW4.5
 
 
Labels (1)
0 Kudos
13 Replies

1,166 Views
CrasyCat
Specialist III
Hello
 
This should work
Can you please check your .map file.
Is there anything allocated in section TestMemory?
Or is the section empty?
 
CrasyCat
0 Kudos

1,166 Views
Xbot
Contributor II
It is is covered by other labels specifically EEPROM_14     = READ_ONLY   0x140800 TO 0x140BFF...etc.
0 Kudos

1,166 Views
CrasyCat
Specialist III
Hello
 
Memory areas (segments) defined in the PRM file should not overlap.
 
Here I assume your objects are allocated in EEPROM_14 and nothing comes into TestMemory.
This is the reason you cannot retrieve its start/end address.
 
Also for HCS12X it is not recommended to defined memory area going across several banks.
I am not sure to understand what you are trying to achieve here, but if the purpose is to test memory on several pages  I would rather recommend you to proceed page after page.
 
HCS12X is a banked architecture after all.
You can decide to go with global addresses, but then also, make sure you do not define a segment (memory area) across a 64K global page boundary.
 
CrasyCat
0 Kudos

1,166 Views
Xbot
Contributor II
Hello,
 
I would like to define a "start" and "end" labels to be used for mpu descriptors. Probably this is not the best solution since code size increase all the time(new versions, etc...).
 
Is there a better solution to this? The purpose of having labels is to not constantly change descriptor ranges.
 
thanks,
0 Kudos

1,166 Views
Xbot
Contributor II
hello all,
 
sorry for the trouble... also want to make things clear. from the memory map below, is it arranged in this order?
 
|---------------- |---> 0x2002
|---------------- |
|-----------------|
|  stack           |
|default ram   |
|xgatexx          |
|shared           |--->0x3fef
------------------
 
prm:
 
SEGMENTS
RAM           = READ_WRITE    0x2002 TO   0x3FEF
 
PLACEMENT
 
stack,default_ram,xgatexx,shared     INTO         RAM
0 Kudos

1,166 Views
CrasyCat
Specialist III
Hello
 
I am not sure I understand what you want to do here.
Are you trying to retrieve start address of stack and end address of shared to put them in a descriptor?
 
Is that what you want to do?
 
CrasyCat
0 Kudos

1,166 Views
Xbot
Contributor II
Yes and no.
 
SSTACK,  DEFAULT_RAM,  SEGDRV_XGATE_SHARED,  SHARED_DATA,   
                        INTO    RAM;
 
I will assign a descriptor for SSTACK, another descriptor for SHARED_DATA. Is this possible? can i retrieve the start and end address for SHARED_DATA even if it doesnt have any objects yet? And Is this method possible? I will also, assign descriptors for EEPROM in the same manner.
 
Hoping for your generousity,
0 Kudos

1,166 Views
CrasyCat
Specialist III
Hello
 
  You can retrieve stack start and end address as follows:
      extern char __SEG_START_SSTACK [];
      extern char __SEG_END_SSTACK [];
 
      #define Start_Stack __SEG_START_SSTACK
      #define End_Stack  __SEG_END_SSTACK
 For SHARED_DATA and EEPROM, if there are no objects allocated in these segment, the __SEG_START and __SEG_END symbols will be set to 0.
 
So you may have to test the value of the pointer and in case of a NULL pointer there is nothing in there and you do not need to initialize a descriptor.
 
CrasyCat
0 Kudos

1,166 Views
mikoran
Contributor II
Can I ask where could we find the declaration for __SEG_START_SSTACK[ ] and __SEG_END_SSTACK[ ]?
 
Since we are using extern char __SEG_START_SSTACK [];
so we expect that it is declared somewhere.
 
Thanks
0 Kudos

1,166 Views
CrasyCat
Specialist III
Hello
 
These symbols are Linker defined symbols.
The linker determines the value of these symbols at link time.
 
They are not explicitly defined anywhere in a source file, but when the linker sees a reference to these symbols he just puts the corresponding address in the code.
 
CrasyCat
0 Kudos

1,166 Views
mikoran
Contributor II
ok thanks a lot..
0 Kudos

1,167 Views
MusikA
Contributor I
Hi,

I'm a newbie to the embedded world. I have here the PRM file.

SEGMENTS
BODY_METHOD3 = READ_ONLY 0xFE8400 TO 0xFE8BF5;
END

PLACEMENT
BODY_METHOD3_SECTION INTO BODY_METHOD3;
END

I'm trying to calculate a CRC16-CCITT for the data in BODY_METHOD3, could I possible use __SEG_START_BODY_METHOD3_SECTION as an array to the BODY_METHOD3 data? If ok, how will it be implemented?

Thanks......
0 Kudos

1,167 Views
CrasyCat
Specialist III
Hello
 
This is a completely different question. For clarity purpose it is recommended to create a new thread for new questions.
 
__SEG_START_BODY_METHOD3_SECTION  can be used to retrieve the start address of section BODY_METHOD3_SECTION .
 
The linker will simply place the symbol at the section start address.
 
It is then up to you to do whatever to want with that array/pointer.
 
CrasyCat
0 Kudos