CW4.5: Out of Non-Banked Flash on 9S12XDT256

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

CW4.5: Out of Non-Banked Flash on 9S12XDT256

Jump to solution
5,560 Views
Sten
Contributor IV
Could somebody give me a hint how to move strings and/or constants from Non-Banked to Banked Flash?
 
My application contains rather much constant tables and strings, and CW want these in non-banked flash. My ROM_4000-segment if filled with the sections NON_BANKED (interrupt routines and such) and ROM_4000_523 (which seems to contain string constants). The ROM_C000-segment is filled with the sections .init, .startdata, .rodata and .rodata1. Of these the rodata-sections are the large ones and they seem to containt program constants and strings.
 
Here is an extract from my PRM-file:
Code:
PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */      _PRESTART,              /* Used in HIWARE format: jump to _Startup at the code start */      STARTUP,                /* startup data structures */      ROM_VAR,                /* constant variables */      STRINGS,                /* string literals */      VIRTUAL_TABLE_SEGMENT,  /* C++ virtual table segment */    //.ostext,                /* eventually OSEK code  */      NON_BANKED,             /* runtime routines which must not be banked */    //COPY                    /* copy down information: moved to banked flash */                              /* in case you want to use ROM_4000 here as well, make sure                                 that all files (incl. library files) are compiled with the                                 option: -OnB=b */                        INTO  ROM_C000, ROM_4000;      DEFAULT_ROM,      COPY                    /* copy down information: how to initialize variables */                        INTO           PAGE_FE,          PAGE_FC, PAGE_FB, PAGE_FA, PAGE_F9, PAGE_F8,                              /* use the following ranges only when same module is NOT used for XGATE code */                              /* PAGE_E0, PAGE_E1, intentionally not listed: assigned to XGATE */                              PAGE_E7, PAGE_E6, PAGE_E5, PAGE_E4, PAGE_E3, PAGE_E2,        PAGE_E0_0;

 
Is there any way to move some of the sections to banked Flash?
 
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,850 Views
CrasyCat
Specialist III
Hello
 
The process to get banked constants or strings is different for HCS12 and HCS12X.
 
Take a look at FAQ 27439 on the Freescale web site.
  go to www.freescale.com and search for FAQ-27439.
 
The second part of the FAQ is dedicated to HCS12X.
 
CrasyCat

View solution in original post

0 Kudos
Reply
13 Replies
1,850 Views
Motoman
Contributor I

All,

Synopsis of Problem:
------------------------
In my project, the non-banked area has run-out of memory and hence I cannot add any more string literals or string constants. In order to overcome the problem I would want to create string literals/constants in STRING_SEG and assign it in the paged memory and access it at runtime using strcpy function. It seems that the strcpy function doesn't seem to work and it is still accessing PPAGE = 0; Please see the steps I  have performed and let me know if any modifications needs to be done.

I am using CodeWarrior V2.0 and the code is being developed in C++.

I am referring to the link below and FAQ-27439 which provided some excellent insight in creating paged string literals.

http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=757&query.id=3812#....


Steps Done:
--------------

1. In the .h file in my project, I declared  const char *__far mystring;   
    *** Question**** mystring is not a global variable, can that be a problem ?

2. In the .c file, I have the following pragma declaration,

   #pragma STRING_SEG __PPAGE_SEG CONST_STRING
       const char *__far mystring = "Good Morning America";            
   #pragma STRING_SEG DEFAULT

*** Question**** Any restriction on where to place the pragma in the code ?

3. Compiler Settings was modified to include -CpPPAGE=RUNTIME,
   done by Edit >> P&E Settings >> Compiler for HCS12 >> Options >> Code Generation >> PPAGE register is used for
     paging (checked this box)

4. Since I couldn't find -DHCS12 as a compiler option among the options in checkboxes, I manually added -DHCS12 to the
    Command Line Argument for the Compiler.

 The Command Line Argument now reads as shown below.

-C++c -Cc -CpPPAGE=RUNTIME -DHCS12 -Lasm=%n.lst -Mb -Ona -OnB -Onbf -Onbt -Onca -Oncn -OnCstVar -One -OnP -OnPMNC -Ont -WmsgSd1048 -WmsgSd1420 -WmsgSd2705 -WmsgSd4000 -WmsgSd4001 -WmsgSd12056

5. Edited lines 74 & 78 LIBDEFS.h file in [install]/lib/HC12c/INCLUDE.
    #define LIBDEF_FAR_CONST_STRINGS  1  
   #define LIBDEF_FAR_STRINGS        1

   ***** Please find the LIBDEFS.H attached along with this post. Could you please verify this file ?

6. Rebuilt the project in  [install]/lib/HC12c/hc12 lib.mcp. Rebuilt using the "Make" option in Project tab.

7. Added DATAPAGE.c from [install]/lib/HC12c/SRC. Moved it higher up than ANSIB.LIB in the Link Order Hierarchy.
***** NOTE****  When I add DATAPAGE.C it gets added among the source files that I have created in my project.. Is this correct ?

8. Did a clean build for my project, the project compiles and loads into the micro. I did check the memory location where the
    constant string I declared, mystring is located and it is placed in the intended memory location, i.e. 0x3D8000.

9. I am referencing mystring in my project using the following code,
     long TestCharPtr;    // debug variable
    TestCharPtr = (long) (mystring + 2);   // assigning address of mystring; TempCharPtr shows value of 0x0002 (lower 4 byte address instead of 0x3d8002)

      strcpy((char *)tempstring, (char *__far)mystring);          // accessing the STRING.C function

Thus the value returned is wrong since I guess it is accessing the wrong address.

Could you please let me know if the steps performed are correct and any thoughts into the problem?


Sincerely,

 

 

LIBDEFS.H

Message Edited by t.dowe on 2009-09-03 06:10 PM
0 Kudos
Reply
1,850 Views
CrasyCat
Specialist III
Hello
 
First note as you are using HCS12CDT256, you should refer to the second part of the FAQ-27439.
The part starting with
    "For HC(S)12X/HC(S)12XE MCUs
    ============================"
 
1. No this should work for global or local pointer variables.
 
2-9 Please follow steps described for HCS12XE project. Data banking is not implemented in the same way for HCS12 & HCS12X.
 
CrasyCat
0 Kudos
Reply
1,850 Views
Motoman
Contributor I
Hello CrasyCat,

I am using MC9S12A256CPVE, Is this different from HCS12 and HCS12X/HC or the 12XE MCU in the way banked strings are implemented?

When I include the pragma below for HC12X/HC or XE, I get a warning that pragma is incorrect and I do not the see string literal assigned to memory as specified in the .PRM file.

   #pragma STRING_SEG __GPAGE_SEG CONST_STRING
       const char *far mystring = "Good Morning America";           
   #pragma STRING_SEG DEFAULT 

Thanks,
Motoman




Message Edited by Motoman on 2008-07-10 03:15 PM
0 Kudos
Reply
1,850 Views
Motoman
Contributor I
Hello CrasyCat,

A surprising thing happened, I had my #pragma assignment kept as a global declaration (i.e. kept above the void main () declaration) and from then on it seems to work fine. I can access my literal using the far pointer but if I keep it was local, i.e inside of a function it looses the extended address and tries to access the data with a 16 bit address with PPAGE = 0;

Any thoughts on why it does that ?

Sincerely,

0 Kudos
Reply
1,850 Views
CrasyCat
Specialist III
Hello
 
Here my recommendation would be to submit a service request to our support team and provide them with a reproducible case.
 
Click here to submit a service request.

Make sure to attach a reproducible project and installed product information to the service request.
To generate the required information:
- Start CodeWarrior
- Open the project
- Select "Help" -> "Pack and Go" and follow instructions on the screen.

Attach the generated .zip file to the SR.
 
CrasyCat
0 Kudos
Reply
1,850 Views
CrasyCat
Specialist III
Hello
 
Then if you are using a MC9S12A256CPVE do not post your question on a thread where the subject specifies 9S12XDT256.
 
This is extremely confusing and you will not get the appropriate answer to your question.
If would have been easier and much clearer for everybody if you would have created a new thread for that.
 
There might be something wrong in your project.
 
I would recommend you to submit a service request for that.

Click here to submit a service request.

Make sure to attach a reproducible project and installed product information to the service request.
To generate the required information:
- Start CodeWarrior
- Open the project
- Select "Help" -> "Pack and Go" and follow instructions on the screen.

Attach the generated .zip file to the SR.
 
CrasyCat
0 Kudos
Reply
1,850 Views
Motoman
Contributor I
Hi All,

This is exactly the problem I am encountering, as mentioned I did the modifications as mentioned in FAQ-27439.  I guess its been sometime since this issue has been revisited.

However pertaining to this I am encountering another which is described below,

1. I change the file LIBDEFS.h as mentioned and rebuilt it. I then opened my application project and recompiled and loaded the code into HCS12. It loads but  wouldn't execute beyond a point. What I see is, it goes into STRING.C program becasue my program uses strcpy and strcat functions and I wonder if chanding the LIBDEF has anything to do with it.

2. Now if I roll-back all the changes I made to LIBDEFF, my application project works fine.

I have some clarifications on keeping banked strings,

1. Can I have a mixture of banked and non-banked strings in my program i.e. some string constants are kept it banked memory while some are kept in the non-banked memory?
2. Do I need to modify the STRING.C library as I am modifying the LIBDEFS.h. The STRING.C includes the LIBDEFS.h file.

Waiting for your answers/suggestions.

Sincerely.
0 Kudos
Reply
1,850 Views
CrasyCat
Specialist III
Hello
 
Yes you can have a mix of banked and non-banked strings in your application.
 
Just make sure to use __far pointer for any pointer to char, which might be assigned a string constant allocated in banked memory.
 
Also all ANSI library function needs then to be called using __far pointer.  Otherwise this will not work.
 
CrasyCat
0 Kudos
Reply
1,850 Views
J2MEJediMaster
Specialist I
Try taking a look at this forum thread and this one, which covers the subject. HTH.

---Tom

0 Kudos
Reply
1,850 Views
Sten
Contributor IV
Thanks Tom, will give them a try.
Sten
 
0 Kudos
Reply
1,850 Views
Sten
Contributor IV
Hi again. Haven't had time to test this before now, and I immedetially run into problems; I can't activate the option -CpPPAGE=RUNTIME, it gives me the error "Error while setting Option "PPage Register is used for paging"".
 
My compiler command line options are: "-CPUHCS12X -D_BootLoader -D__FAR_DATA -D__NO_FLOAT__ -Lasm=%n.lst -Mb -Ot -Onf -OiLib=a -OnB=abl -OnCstVar -OnPMNC -PSegObj -TuE". Do I have some option that causes a conflict with the PPAGE=RUNTIME option?
 
I also get the same error when trying to rebuild the ansixbi.lib library (which have the following command line "-CpDirect61440 -CPUHCS12X -D__NO_FLOAT__ -F2 -Mb -NoPath -Os -W2" )
 
/sten
 


Message Edited by Sten on 2007-06-26 08:33 AM
0 Kudos
Reply
1,851 Views
CrasyCat
Specialist III
Hello
 
The process to get banked constants or strings is different for HCS12 and HCS12X.
 
Take a look at FAQ 27439 on the Freescale web site.
  go to www.freescale.com and search for FAQ-27439.
 
The second part of the FAQ is dedicated to HCS12X.
 
CrasyCat
0 Kudos
Reply
1,850 Views
Sten
Contributor IV
Excellent! That was exactly what I was looking for. Thanks CrazyCat!
Sten
 
0 Kudos
Reply