8787     Note that address is different on the 105x and the 106x. */  
8888  m_ocram               (RW)   : ORIGIN  = MBED_RAM_BANK_SRAM_OC_START, LENGTH  = MBED_RAM_BANK_SRAM_OC_SIZE
8989
90- #if  MBED_TARGET_MIMXRT1060 
90+ #ifdef  MBED_RAM_BANK_SRAM_OC2_START 
9191  /*  OCRAM2 bank -- extra RAM, available on MIMXRT106x only. */ 
9292  m_ocram2              (RW)   : ORIGIN  = MBED_RAM_BANK_SRAM_OC2_START, LENGTH  = MBED_RAM_BANK_SRAM_OC2_SIZE
9393#endif 
@@ -269,20 +269,6 @@ SECTIONS
269269
270270  __NDATA_ROM = __ram_function_flash_start + SIZEOF (.ram_function );
271271
272-   /*  Store crash data RAM at the end of OCRAM (which is otherwise unused).
273-      Note that the ROM bootloader clobbers the first part of OCRAM, so we have to put this at the end. */  
274-   __CRASH_DATA_RAM_START__ = ORIGIN (m_ocram) + LENGTH (m_ocram) - M_CRASH_DATA_RAM_SIZE; /*  Create a global symbol at data start */ 
275-   .crash_data_ram  __CRASH_DATA_RAM_START__  :
276-   {
277-     . = ALIGN (8 );
278-     __CRASH_DATA_RAM__ = .;
279-     KEEP (*(.keep .crash_data_ram ))
280-     *(.m_crash_data_ram )     /*  This is a user defined section */ 
281-     . += M_CRASH_DATA_RAM_SIZE;
282-     . = ALIGN (8 );
283-     __CRASH_DATA_RAM_END__ = .; /*  Define a global symbol at data end */ 
284-   } >  m_ocram  :crash_data_ram
285- 
286272  /*  Always store noncacheable data (e.g. DMA descriptors) in DTCM, since this memory
287273     is always cache coherent. */  
288274  .ncache.init  :
@@ -342,13 +328,12 @@ SECTIONS
342328  __end__ = .;
343329  PROVIDE (end = .);
344330
345-   .heap   (NOLOAD) :
331+   .heap_0   (NOLOAD) :
346332  {
347-     __HeapBase = .;
348-     . =  ORIGIN (m_dtcm) + LENGTH (m_dtcm) - STACK_SIZE;
349-     __HeapLimit = .;
350-     __heap_limit = .; /*  Add for _sbrk */ 
351-   } >  m_dtcm  :ram_noinit
333+       PROVIDE (__mbed_sbrk_start_0 = .);
334+       . =  ORIGIN (m_dtcm) + LENGTH (m_dtcm) - STACK_SIZE;
335+       PROVIDE (__mbed_krbs_start_0 = .);
336+   } > m_dtcm
352337
353338  /*  Reserve space for stack (even though stack is always at the end of DTCM regardless
354339     of where this section is located) */  
@@ -363,6 +348,39 @@ SECTIONS
363348  __StackLimit = __StackTop - STACK_SIZE;
364349  PROVIDE (__stack = __StackTop);
365350
351+   /*  Store crash data RAM at the end of OCRAM (which is otherwise unused).
352+      Note that the ROM bootloader clobbers the first part of OCRAM, so we have to put this at the end. */  
353+   __CRASH_DATA_RAM_START__ = ORIGIN (m_ocram) + LENGTH (m_ocram) - M_CRASH_DATA_RAM_SIZE; /*  Create a global symbol at data start */ 
354+ 
355+   /*  Second heap region. Use OCRAM2 if available, otherwise use OCRAM.
356+    * TODO https://github.com/mbed-ce/mbed-os/issues/413 Use SDRAM once this bug is fixed. */  
357+ #ifdef  MBED_RAM_BANK_SRAM_OC2_START
358+   .heap  (NOLOAD) :
359+   {
360+       PROVIDE (__mbed_sbrk_start = .);
361+       . += (ORIGIN (m_ocram2) + LENGTH (m_ocram2));
362+       PROVIDE (__mbed_krbs_start = .);
363+   } > m_ocram2
364+ #else 
365+   .heap  (NOLOAD) :
366+   {
367+       PROVIDE (__mbed_sbrk_start = .);
368+       . = __CRASH_DATA_RAM_START__;
369+       PROVIDE (__mbed_krbs_start = .);
370+   } > m_ocram2
371+ #endif 
372+ 
373+   .crash_data_ram  __CRASH_DATA_RAM_START__  :
374+   {
375+     . = ALIGN (8 );
376+     __CRASH_DATA_RAM__ = .;
377+     KEEP (*(.keep .crash_data_ram ))
378+     *(.m_crash_data_ram )     /*  This is a user defined section */ 
379+     . += M_CRASH_DATA_RAM_SIZE;
380+     . = ALIGN (8 );
381+     __CRASH_DATA_RAM_END__ = .; /*  Define a global symbol at data end */ 
382+   } >  m_ocram  :crash_data_ram
383+ 
366384  .ARM .attributes  0  : { *(.ARM .attributes ) }
367385
368386  /*  Teensy model identifier symbol (used by Teensy Loader) */ 
0 commit comments