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 problem

Hello

I am working with very big array. So i decide to use malloc to allocate the memory as bellow.

http://pastebin.com/778bb0cT

The problem is the buffers cannot be allocated correctly. I starts with heap size 10000, only buffer_a is allocated. If I inscrease the heap to 20000, both buffer_a and buffer_b cannot be allocated. I tried to change the heap size to very big. But it doesn't work. Please help me to solve this problem. Here is the linker.cmd file:

-stack         0x4000   /* PRIMARY STACK SIZE    */
-sysstack    0x4000   /* SECONDARY STACK SIZE  */
-heap       0x70000   /* HEAP AREA SIZE        */

MEMORY
{
    MMR     (RW) : origin = 0000000h length = 0000C0h /* MMRs */
    VEC     (RX) : origin = 00000C0h length = 000300h /* on-chip ROM vectors */
    DARAM   (RW) : origin = 0000400h length = 00FC00h /* on-chip DARAM  */
    SARAM   (RW) : origin = 0010000h length = 100000h /* on-chip SARAM  */
}

SECTIONS
{
    vectors     : > VEC
    .text       : > DARAM
    .stack      : > SARAM
    .sysstack   : > SARAM
    .data       : > DARAM
    .bss        : > DARAM
    .cinit         : > DARAM
    .const         : > DARAM
    .switch        : > DARAM
    .sysmem     : > SARAM
    .cio        : > DARAM
}

  • This might be a word address / byte address mixup.

    C55x memory is 8-bit byte-addressable for code and 16-bit word-addressable for data. The assembler and linker keep track of the addresses, relative offsets, and sizes of the bits in units that are appropriate for the given section: words for data sections, and bytes for code sections.

    See that the origin of SARAM is 0008000h below... Try shifting your values one bit.

    MEMORY
    {
        MMR     (RW) : origin = 0000000h length = 0000c0h /* MMRs */
        DARAM_0 (RW) : origin = 00000c0h length = 001f40h /* on-chip DARAM 0 */
        DARAM_1 (RW) : origin = 0002000h length = 002000h /* on-chip DARAM 1 */
        DARAM_2 (RW) : origin = 0004000h length = 002000h /* on-chip DARAM 2 */
        DARAM_3 (RW) : origin = 0006000h length = 002000h /* on-chip DARAM 3 */
        SARAM_0 (RW) : origin = 0008000h length = 008000h /* on-chip SARAM 0 */
        SARAM_1 (RW) : origin = 0010000h length = 008000h /* on-chip SARAM 1 */

        SAROM_0 (RX) : origin = 0ff0000h length = 008000h /* on-chip ROM 0 */
        SAROM_1 (RX) : origin = 0ff8000h length = 007f00h /* on-chip ROM 1 */
        VECS    (RX) : origin = 0ffff00h length = 000100h /* on-chip ROM vectors */
    }
     
    SECTIONS
    {  
        .cinit          : > SARAM_0
        .text           : > SARAM_0    ALIGN = 4
        .bss            : > SARAM_0
        .stack          : > DARAM_0
        .sysstack       : > DARAM_0

    Hope this helps,
    Mark

  • Refer to TMS320C55x Assembly Language Tools v 4.4 User's Guide

    http://www.ti.com/lit/ug/spru280i/spru280i.pdf

  • Hello,

    I tried the memory map as you post above, but it doesn't work as well. As I calculate, each buffer needs about 10000h memory length. So, about 20000h is enough. I map the DARAM and SARAM base on the addresses in the datasheet of C5515 DSP.

    Thanks