AnsweredAssumed Answered

Best practice to have a 16 bit heap on ADSP21479

Question asked by mlomonaco on Jul 30, 2014
Latest reply on Aug 21, 2014 by mlomonaco

Hello everyone,

I am trying to manipulate the standard heap definition in LDF trying to convert it to 16 bit width.

Using CCES and the default app.ldf I started changing simply this line:


mem_block3_dm32         { TYPE(DM RAM) START(0x000E0000) END(0x000E7FFF) WIDTH(32) }

mem_block3_dm32         { TYPE(DM RAM) START(0x001C0000) END(0x001CFFFF) WIDTH(16) }


I enabled the heap_debugging features in the dxe and at the first malloc() I got this:


A fatal error or exception has occurred.

  Description:   A heap's internal data structures have become corrupted.

  General Type:  LibraryError

  Specific Type: HeapIsCorrupt

  General Code:  0x7

  Specific Code: 0x130

  Error Value:   0x001c0002

  Error PC:      0x0012a070


Given the block segmentation of memory in SHARCs I understand that this trick of using 16 bit words in internal memory must be a well known and used practice (I found here ADSP-21479 LDF question  a similar but it didnt satisied me 100%).

In such thread it says that the heap lib MUST obey this constraint:

"Because heap has a 6-word control block at the start of "seg_heap" that is initialized by the start-up code before main() is called. You will therefore need to ensure that "seg_heap" is at least 6 words in size."


I guess that by defining the 16 bit memory segment I am losing the requested 6 32 bit words to be used as "ensured" by the heap library.

My question is therefore natural and straightforward: how do I setup the LDF in order to keep those 6 32 bit words and at the same time provide the remaining space in 16 bit words to be used by the heap functions malloc/free?


Thank you