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.

malloc() with beaglebone (StarterWare)

Hi guys

I am trying to transfer files from my PC to my beaglebone using basic serial communication. For this I have built my own application.

When I use malloc() to allocate memory for the file which is coming it returns NULL when the file size is larger than 10.3KB (It works for 8.68KB but not for 10.3KB). So somewhere in between these two sizes malloc fails. My beaglebone has 256MB memory and in the linker command file, sysmem is set to use DDR_MEM (.sysmem  : load > DDR_MEM)

When i do static allocation there is no problem (test with 10+ MB).

Any ideas? May some memory page allignment issuse?

This is the code snippet which fails:


fileReceiveBuffer = (char*) malloc (bytesToReceive);

  • Sounds like a compiler or OS question to me.

    The BeagleBone is not a Cortex M4 anyway is it? If not  -- maybe a different forum would be more appropriate.

    Only CORTEX M4 questions are/will be answered here. ;-)

  • Hi Dave

    First of all, thanks for moving my post to the correct forum.

    The problem is not caused by OS since i am using StarterWare (no OS).

    I did some more experiments and found that it fails at exactly 8181 bytes (i.e. (2^13)-12=8180 works)

    It must be an error with the compiler (settings), but I don't know where to start looking for errors.

  • Bogi I ran into similar problems and it seems starterware does not support applications using standard malloc/calloc. If you look at the 2.00.00.07 release notes, towards the bottom of the page under "What's Not Supported", it says "StarterWare 02.00.00.07 Startup Code neither call any library nor initializes heap. Hence does not perform initializations required for malloc/calloc."

    I am curious to know what it would take to work around this.

    Hope that helps

    Jonathan

  • I can see that the settings from the linker command file are not the same as the settings in the .map file outputted by the compiler. I will try to find out why.

    Screendump of linker command file:

    Screendump of map file.

  • jon fleming said:
    Bogi I ran into similar problems and it seems starterware does not support applications using standard malloc/calloc. If you look at the 2.00.00.07 release notes, towards the bottom of the page under "What's Not Supported", it says "StarterWare 02.00.00.07 Startup Code neither call any library nor initializes heap. Hence does not perform initializations required for malloc/calloc."

    The release notes for StarterWare 02.00.01.01 no longer says that malloc/calloc isn't supported.

    The support for malloc/calloc comes from the compiler Run Time Library. E.g. using StarterWare 02.00.01.01 and TI ARM compiler was able to get a StarterWare example to use malloc.

    In StarterWare 02.00.01.01 none of the StaterWare code makes use of malloc/calloc, so malloc/calloc won't be included in the image unless the application makes use of malloc/calloc.

    Bogi Magnussen said:
    The problem is not caused by OS since i am using StarterWare (no OS).

    I did some more experiments and found that it fails at exactly 8181 bytes (i.e. (2^13)-12=8180 works)

    It must be an error with the compiler (settings), but I don't know where to start looking for errors.

    When compiling with CCS and the TI ARM compiler there are two ways the heap size can be set:

    a) From CCS Project Properties -> Build -> ARM Linker -> Basic Options -> Heap Size for C/C++ dynamic memory allocation

    b) With a -heap directive in a linker command file. The value of a -heap directive in a linker command file overrides the value set in the CCS Project Properties.

    The linker command files for the StaterWare examples contain a -heap directive, so that value needs to be increased to allocate more heap space.