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 with Error: memory map prevetned reading 0x00000000

Other Parts Discussed in Thread: OMAPL138

Hello

I am using CCS v6 and LCDK6748.

I have an struct with two int and a pointer to an array.

When I initialize the struct, I write the int with some data and I reserve the space for the array with malloc.

Then I try to fill the array, but when i try to read the array is empty.

I debug my code and the array shows this:

Error: Memory map prevented reading 0x00000000.

Could you help me??

What is wrong??

This is the code:

//The struct

struct OO {
int ancho;
int alto;
unsigned char *imagen;
};

//the function to initialize

int CrearG(struct OO *oo, int ancho, int alto)
{
oo->ancho=ancho;
oo->alto=alto;
oo->imagen=(unsigned char *)malloc(((oo->ancho)*(oo->alto))*sizeof(unsigned char));
return 1;
}

//In the main

for(i=0; i<oo->ancho*oo->alto; i++)
{
OO->imagen[i]=(unsigned char) i;
}

Thank you

Kind Regards

  • You are getting that message as the debuggers memory map prevents it from accessing that location in memory.  Basically it has been told by the target configuration that there is no memory there or that it is not readable.

    When I look at the memory map for my OMAPL138, which has the same DSP on it as C6748 I see that there is no memory from 0x0 to 0x6FFFFF.  When in your debug session if you go to Tools -> Memory Map it will open a window that shows the memory map.  It should show the same for you.

    So now the question is why is your array going there?  When I look at the linker command file for C6748 it does not define any memory at 0x00000000.  Do you have a linker command file (.cmd) in your project?  It is essential to have one as this defines to the linker where valid memory is.  When you create a new project in CCS it should add the appropriate one for you.  If yours is missing the file is located in: <your install dir>\ccsv6\ccs_base\c6000\include

    Regards,

    John

  • I am using the cmd file of the gpio example which is the Starware.

    This is the file:

    // ============================================================================
    // Linker Command File for Linking c674 DSP Programs
    //
    // These linker options are for command line linking only. For IDE linking,
    // you should set your linker options in Project Properties.
    // -c Link Using C Conventions
    // -stack 0x1000 Software Stack Size
    // -heap 0x1000 Heap Area Size
    // ===========================================================================
    -c
    -stack 0x1000
    -heap 0x1000

    // ============================================================================
    // Specify the System Memory Map
    // ============================================================================
    MEMORY
    {
    L1P: o = 0x11E00000 l = 0x00008000
    L1D: o = 0x11F00000 l = 0x00008000
    L2: o = 0x11800000 l = 0x00040000
    DDR2: o = 0xC0000000 l = 0x08000000
    }

    // ============================================================================
    // Specify the Sections Allocation into Memory
    // ============================================================================
    SECTIONS
    {
    .cinit > DDR2 // Initialization Tables
    .pinit > DDR2 // Constructor Tables
    .init_array > DDR2 //
    .binit > DDR2 // Boot Tables
    .const > DDR2 // Constant Data
    .switch > DDR2 // Jump Tables
    .text > DDR2 // Executable Code
    .text:_c_int00: align=1024 > DDR2 // Entrypoint

    GROUP (NEARDP_DATA) // group near data
    {
    .neardata
    .rodata
    .bss // note: removed fill = 0
    } > DDR2
    .far: fill = 0x0, load > DDR2 // Far Global & Static Variables
    .fardata > DDR2 // Far RW Data
    .stack > DDR2 // Software System Stack
    .sysmem > DDR2 // Dynamic Memory Allocation Area

    .cio > DDR2 // C I/O Buffer
    .vecs > DDR2 // Interrupt Vectors
    }

    Any idea?? Why is my array going to 0x00000000?

    Thank you

    Kind Regards

  • Could you look at the structure in the memory view and see which address the pointer to the array is pointing to?

    I am likely going to have to move this one into the Compiler forum.

  • This is the information:

    The struct has a valid adress but the array goes to 0x00000000.

    Any idea??

    Thank you

    Kind Regards

  • Hello

    I think I have found the problem.

    If I try to reserve an array with less elements, it works.

    My array has 307200 elements, it does not work. But if I try with 1000 elements array, it works.

    Can I change something to work with a 307200 elements array?

    Thank you

    Kind Regards

  • Javi UM said:
    Can I change something to work with a 307200 elements array?

    If your array is allocated from the heap, then you have to increase the space allocated to the heap by the linker.

    Under CCS Project Properties -> Build -> C6000 Linker -> Basic Options increase the value of "Heap Size for C/C++ dynamic memory allocation (--heap_size,-heap)".

  • The previous post on how to increase heap size is correct.  In addition, this code ...

    Javi UM said:
    oo->imagen=(unsigned char *)malloc(((oo->ancho)*(oo->alto))*sizeof(unsigned char));
    return 1;

    ... will cause problems.  You must always check that malloc does not return NULL, and have a plan on what to do if it does.

    Thanks and regards,

    -George