Keil Logo

Allocate HEAP into external SDRAM with Keil-RTX

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
George Belyakov
Posted
24-Nov-2015 08:09 GMT
Toolset
ARM
New! Allocate HEAP into external SDRAM with Keil-RTX

Hello!
I'm developing an application which requires the heap to be located in a 32MB off-chip SDRAM. I'm using Keil RTX in the project. The problem is the application falls when a function malloc() is calling.

The crystall used is STM32F746IG. The external SDRAM is MT48LC16M16A2P. There are absolutely clear project with only RTX_CM4.lib, RTX_Conf_CM.c, startup_stm32f746xx.s and system_stm32f4xx.c files.
I have #define DATA_IN_ExtSDRAM in system_stm32f4xx.c file to initialize SDRAM.
If there is no scatter file in the project - the memory is working correctly: in this case i can write some data to the memory and read from one in [0xC0000000 to 0xC2000000] 32MB range.

But if i have create the next scatter file to allocate HEAP into external SDRAM, there is an hard-fault handler exception when the malloc() function is called.

LR_IROM1 0x08000000 0x00100000  {    ; load region size_region
  ER_IROM1 0x08000000 0x00100000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_RAM1 0xC0000000 0x02000000  {  ; RW data
   ;.ANY (+RW +ZI)
   *(HEAP)
  }
  RW_IRAM1 0x20010000 0x00040000  {
   .ANY (+RW +ZI)
  }
}

start-up file:
Stack_Size      EQU     0x00000400

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp


Heap_Size       EQU     0x00000200

                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit

                PRESERVE8
                THUMB

main.c listing where malloc() is calling is presented below:

#include "cmsis_os.h"
#include <stdlib.h>

int main(void)
{
    uint16_t* p;
    uint16_t data;

    p = malloc(10);

    *p = (uint16_t)0x22DD;

    data = *p;
}

There is no Microlib in the project!
One interesting thing is that if Microlib is checked in the project settings, the malloc() function is work correctly, but failed without it. But using RTX without microlib is very important for our projects.

And the other interesting thing is that i have absolutely identical project on the STM32F407IGT6 crystal with external SRAM IS61LV51216, and there is no such problem on them. I have identical scatter file, identical #define DATA_IN_ExtSRAM, and no microlib. But malloc() calling is work correctly.

Read-Only
Author
Per Westermark
Posted
24-Nov-2015 08:38 GMT
Toolset
ARM
New! RE: Allocate HEAP into external SDRAM with Keil-RTX

And before worrying about function of malloc() - have you tried if your own code can correctly read and write to the external RAM?

Read-Only
Author
George Belyakov
Posted
24-Nov-2015 12:11 GMT
Toolset
ARM
New! RE: Allocate HEAP into external SDRAM with Keil-RTX

Yes, i tried write/read data at full range of memory, and it works correctly. I made a full test with write-read operations using pointers for each address in [0xC0000000 to 0x02000000] range.

Read-Only
Author
Paul Krechka
Posted
23-Jan-2017 10:49 GMT
Toolset
ARM
New! Allocate HEAP into external SDRAM with Keil-RTX

Hi there, i've faced with th same problem.
Did you solve them?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.