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.

Problem in using malloc with sysbios

Other Parts Discussed in Thread: SYSBIOS

Hi,

      I am using SYSBIOS 6.32.5.54 with CCS 5.1. In my application, I needed to use dynamic memory so i use malloc function.

I have choose 
             SYSBIOS Library type = Custom and 
             used only modules which my application need. 
              Not included any Memory modules in my .cfg file.
              Default heap size = 0

and i compiled the code and debuged it and found that it was returning me null.

now when i change the Default heap size = 1024
then i get following errors

Unresolved symbol ti_sysbios_heaps_HeapMem_alloc__E in file C:\Users\ AMIT\workspace_5_1\ my_project\ Debug\configPkg\package\cfg\base_board_p430X.o430X 
Unresolved symbol ti_sysbios_heaps_HeapMem_free__E in file C:\Users\ AMIT\workspace_5_1\ my_project\ Debug\configPkg\package\cfg\base_board_p430X.o430X 
Unresolved symbol ti_sysbios_heaps_HeapMem_getStats__E in file C:\Users\ AMIT\workspace_5_1\ my_project\ Debug\configPkg\package\cfg\base_board_p430X.o430X 
Unresolved symbol ti_sysbios_heaps_HeapMem_init__I in file C:\Users\ AMIT\workspace_5_1\ my_project\
Debug\ configPkg\package\cfg\base_board_p430X.o430X
Unresolved symbol ti_sysbios_heaps_HeapMem_isBlocking__E in file C:\Users\ AMIT\workspace_5_1\ my_project\ Debug\configPkg\package\cfg\base_board_p430X.o430X  

If i Change Default heap size = 1024 with SYSBIOS Library type = instrumented or non-instrumented then no errors.

I have included following header files
xdc/runtime/IHeap.h
xdc/runtime/System.h
xdc/runtime/Memory.h 
ti/sysbios/heaps/HeapMem.h
 

How to remove this errors with custom library types?

What is the difference between Instrumented, Non instrumented and custom Library types. I have read user guide but cant understand exactly.

and what is the standard way to use Dynamic memory allocation with sysbios.

Please reply me ASAP.

Thanks,
Amit Bhorania

  • Amit Bhorania

    I am not sure about the sysbios which you are using. But, suggestion is to look for available  Dynamic Mem alloc API's like Utils_memAlloc(). Please refer your Utils directory for the same.

  • Hi Amit,

    which version of XDCtools are you using and what MSP430 device?

    • LibType_Instrumented — The library supplied is prebuilt with logging and assertions enabled.
    • LibType_NonInstrumented — The library supplied is prebuilt with logging and assertions disabled.
    • LibType_Custom — This option builds the SYS/BIOS library from sources using the options specified by customCCOpts. Only the modules and APIs that your application needs to access are contained in the resulting executable. Program optimization is performed to reduce the size of the executable and improve its performance. Enough debug information is retained to allow you to step through the application code in CCS and locate global variables.

    I'd check your .map file. You're running out of RAM for your heap on your MSP430. You might want to try turning off your Logging options.

  • Hi Ravikiran,

                           Thanks for your quick reply. I have tried to use Memory_alloc() provided by SYS-BIOS. Its working but it works only with instrumented or non-instrumented library type. I want to run it with custom library type.

    Thanks,
    Amit Bhorania 

  • Hi Tom Kopriva,

                                 Thanks for your quick reply. Your explanation is very helpful. I have some questions in that.

    1. What is meaning of assertions and how it is used in SYSBIOS? Is it useful in our application?

    2. for LibType_Custom, How to give customCCopts ?

    3. Do we need to give information to SYSBIOS about which modules we are using in our application so that it will include only that modules in executable or
         it will automatically determine the modules from the APIs which we have used?

    I have allocated 1K of heap memory and i am using only 200 bytes. I have attached map file.

    Thanks,
    Amit

    6266.my_project.txt

  • Amit,

    Amit Bhorania1 said:

    1. What is meaning of assertions and how it is used in SYSBIOS? Is it useful in our application?

    2. for LibType_Custom, How to give customCCopts ?

    See the FAQ wiki page.

    Amit Bhorania1 said:
    3. Do we need to give information to SYSBIOS about which modules we are using in our application so that it will include only that modules in executable or
         it will automatically determine the modules from the APIs which we have used?

    Yes, you need to add the modules you are planning to use in your application. If you use grace, it will update your .cfg file with the modules that you select.

    Start with a SYS/BIOS project from the TI Resource Explorer. It will import a .cfg file with commonly used modules.

  • Thanks for your help....

    - Amit Bhorania