Any documentation on LPC1788 startup code for Keil Real View compiler??

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

Any documentation on LPC1788 startup code for Keil Real View compiler??

888 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpc_learner on Wed Jun 20 04:19:04 MST 2012
Hi all,
Can any body suggest me to get the detailed information about lpc1788 startup code for Keil Real view compiler??

I am really confusing about variable memory allocation.

local variable, global variable, and const variables memory allocation is making mess up..

So, please can any one provide the details regarding this..??


Thank u in advance..
Labels (1)
0 Kudos
3 Replies

706 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by PhilYoung on Fri Jun 22 10:57:39 MST 2012
I have to admit this is a bit surprising, however if you look at the map file you can see what it placed in RO-Data, this will point you in the direction to fix it.
without specific details of the application and linker script it's difficult to say, this could be due to some section alignment issues, or some code being plac ed in RAM for example, this could cause the code image to be placed in RO-Data.

regards

Phil.
0 Kudos

706 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpc_learner on Wed Jun 20 22:58:20 MST 2012
Hi PhilYoung,

Thank you for giving me very nice info about start up code which was a little bit miserable thing for me. I just have some doubts on this topic. May i ask your answers for these??

I am using Keil Real view compiler for lpc1788 controller. It has 512k flash and 96k RAM memory as you already know it.
After some programming on this, memory consumption is like this.

Program Size: Code=88112 RO-data=32960 RW-data=3544 ZI-data=27896


Now, i observed something after adding one array in main function, which i am not getting why it is happening like this?

    main{
    
    char* n[]={"name1","name2","name3"};
    
    while(1);
    };


after adding this array,

Program Size: Code=88132 RO-data=42644 RW-data=3544 ZI-data=27896

How it is increasing RO-Data 9.4k bytes at a time.

I changed it to const char* n[],and char n[3][5].
And i removed 2 strings out of that, even though it showing same increment in RO-Data.

And i need to store more data i mean some data base type of stuff for my project. So, how can i achieve it with out getting memory exceeding error.

Thank you sir.

Pardhu
0 Kudos

706 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by PhilYoung on Wed Jun 20 12:59:16 MST 2012
The default keil setup code needs to be configured to allocate sufficient stack and heap space, this can be done with the config wizard.
There are a number of things to consider when choosing the heap size, for example if you are writing C++ and instantiate static objects where a destructor is declared then the startup code will allocate memory to build a table for callng the destructors on exit, which uses malloc and therefore needs a heap defining.
Similarly if you use semi-hosting then it also requires heap space, if you are using neither of these and don't explicitly call malloc then you probably don't need a heap ( unless you handle exceptions ).

Otherwise, for all statically allocated objects the linker will allocate space for them in data, and all dynamic objects ( variables in functions etc ) they will be on the stack.

initialized variables are set up by the startup code and placed in RW Data, zero'd variables are placed in ZI data, constants are placed in RO Data, code is placed in code.
initialized data is set up by the startup code, there is not a literal copy of it in the code since the Keil tools use compression, so the startup code decompresses this before calling main.

you can of course define whatever sections you want and place anything in them using a custom linker script, but by default Keil will handle everything for you, just ensure that the stack and heap are large enough, do this by opening the startup.s file in the project and switching to the config screen where you can use a menu to change the sizes.

to find out how much stack you need, you can compile with all options selected on the linker listing section in the listing tab, then it produces an HTML file listing the functions and there callers / callees and required stack size ( static call graph ), this lists the maximum stack size that it can determine.

regards

Phil.
0 Kudos