This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F28335 not enough memory?



Hi there,

I got an linker error for my project

"C:/Users/foo/cmd/F28335.cmd", line 146: error: 
run placement fails for object ".ebss", size 0x1026 (page 1). Available
ranges:
RAML4 size: 0x1000 unused: 0x1000 max hole: 0x1000
warning: entry-point symbol other than "_c_int00" specified: "code_start"
error: errors encountered during linking;
"C:/Users/foo/Debug/foo.out" not built


If I use malloc, it links with no problem. However, I suspect there might be still problem since I got strange behavior after running the problem for several hours. The problem is, say I have an array foo,
And foo[0] and foo[1] ended up point both to address 0... I suspect the malloc is buggy. 
foo was allocated space
foo = (my_struct_name*)malloc(sizeof(my_struct_name)*MY_SIZE);

So I changed foo to be static allocated.
fmy_struct_name foo[MY_SIZE];

And the linker error showed up.

My linker parameters are -stack0x400 and -heap0x1100.


Please help!
  • Hi Alfred, the linker error tells you that you did not allocate enough RAM for global (and static local) variables. These are placed by tha compiler in th e.ebss section. Try increasing the size of .ebss section. As for the "buggy malloc", you did allocate 0x1100 words for heap but until we know size of your struct that you are trying to dynamically allocate (use size of operator) we really can not help you any further. My guess is that dynamic allocation requires some overhead (maybe TI guy can tell you how much is that) and the code silently fails because you do not check the return address from malloc (usually if it is 0 it means that malloc was not able to allocate the required block). Regards, Mitja
  • Hi Mitja,

    Thank you so much for replying. I guess "buggy" is not an appropriate word. It is likely I did understand correctly.

    Would you please tell me how I can increase e.ebss section in CCS4 or CCS3? I was assuming those global variables (declared outside of main) are in the heap, because I thought it should be on the statck... I guess they should be in e.ebss

    Thanks again!

    Alfred

     

  • Alfred Zhong said:
    Would you please tell me how I can increase e.ebss section in CCS4 or CCS3?

    .ebss is allocated within the linker command file.  It will have a '.cmd' extension in your project.  In this file you tell the linker what memory is available and how you would like it allocated (which sections generated by the tools go to which memory regions).

    This wiki may be helpful in understanding: http://processors.wiki.ti.com/index.php/C28x_Compiler_-_Understanding_Linking

    Alfred Zhong said:
    I was assuming those global variables (declared outside of main) are in the heap, because I thought it should be on the statck... I guess they should be in e.ebss

    The wiki page has a table the explains the common sections and what within a C application would generate such.

    For even more info on the linker command file - there is TMS320C28x Assembly Language Tools User's Guide www.ti.com/lit/spru513

    Regards

    Lori

  • Hi Alfred,

    every area allocation is designed by the compiler using the linker file you supplied ( .cmd file that is NOT the "_processorName_Headers_nonBIOS.cmd" )
    On the examples, that file is not even on the project, it's just pointed on the properties to \_your_processor_common\cmd\_xxxx_.cmd

    If that's what your project is doing I suggest to create a new .cmd file inside the project folder itself, copy from the one that it is currently using and then starting tweaking on your project specific without changing the original one.

    To see what file is your project using, there are 2 places to check: 
    - project properties -> General -> Advanced Settings -> Linker command file:
    - project properties -> C2000 Linker -> File Search Path -> "Include library file or command file as input" 

    That is using CCS 5, it might be different on your version. Also remember "_processorName_Headers_nonBIOS.cmd" must stay on the project, it's the other linker I'm talking about. The one that maps MEMORY and SECTIONS.

     So yeah, remove from this configuration the generic one and put the one specific to your project so you can start tweaking your project to your needs.

    In the SECTIONS area of that file you'll see each ... well... secion!

    on one project I'm working at, it's defined as:

    .ebss               : > RAML2       PAGE = 1

    RAML2 is where it's allocating and PAGE is the data memory. You could do something like:

    .ebss               : >> RAML1 | RAML2 | RAML2       PAGE = 1

    that way the compiler will try to use all those 3 RAM blocks to allocate your memory. But be careful, if you're using DMA you don't want to mix DMA used memory with others.

    happy coding!

  • Thank you all for replying!

    I think I found that why malloc is "buggy". I put linker option is -stack0x400 and -heap0x1100.

    I guess the heap is too big and when I call malloc, it may allocate some memory in the stack and cause problems. It would be nice to have the linker tell that the heap size is not reasonable and it will hit the stack. However it didn't.

    As to the .ebss, I am still interested in knowing more about it. 

    So how big is a page here? I don't have RAML2 on my F28335. Can you point my to the source about configuring the F28335.cmd file?

    Thanks again!

    Alfred

  • Alfred Zhong said:

    I guess the heap is too big and when I call malloc, it may allocate some memory in the stack and cause problems. It would be nice to have the linker tell that the heap size is not reasonable and it will hit the stack. However it didn't.

    In general I would not suggest using any dynamic memory allocation unless you truely need allocation that can change at runtime.  The linker cannot give you any help here because the amount of memory you are going to grab is not known until runtime.  A fixed-size buffer is much more stable and deterministic.   Here is an article on memory management in embedded systems that you may find interesting: http://www.barrgroup.com/Embedded-Systems/How-To/Malloc-Free-Dynamic-Memory-Allocation

    Alfred Zhong said:

    As to the .ebss, I am still interested in knowing more about it. 

    .ebss is described in the compiler reference guide: www.ti.com/lit/spru514

    Alfred Zhong said:
    So how big is a page here?

    [

    I'm assuming you are referencing a data page.  On the 28x it is 64 16-bit words.  In C you don't need to worry about the data page size.

    Alfred Zhong said:
    Can you point my to the source about configuring the F28335.cmd file?

    I'm not sure I understand the question.  Is it related to the wiki page: http://processors.wiki.ti.com/index.php/C28x_Compiler_-_Understanding_Linking

    -Lori