cancel
Showing results for 
Search instead for 
Did you mean: 

Locate Heap in SDRAM

z1060
Associate II
Posted on November 20, 2014 at 15:39

Hello,

I have STM32f429 discovery board and I

want to

locate heap in SDRAM.

SDRAM adress is 0xD0000000, size 0x800000.

I use the

Keil uvision 4.

How to

configure

Keil and my code?

#understand-your-tools #stm32f429
5 REPLIES 5
Posted on November 20, 2014 at 18:06

You'd modify the heap in startup_stm32f4xx.s, and then create a scatter file to direct the HEAP section into the memory area you've described for the SDRAM

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
z1060
Associate II
Posted on November 20, 2014 at 18:36

It is possible in more detail? What it is necessary to add to the scatter file?

Posted on November 20, 2014 at 18:37

// STM32 Keil SDRAM HEAP STM32F429I-DISCO - sourcer32@gmail.com
// Use MicroLIB checked in options
// Use Scatter file in Linker options (not Memory Layout from Target Dialog)
/* heap.sct
LR_IROM1 0x08000000 0x00200000 { ; load region size_region
ER_IROM1 0x08000000 0x00200000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00030000 { ; Internal SRAM
.ANY (+RW +ZI)
}
RW_IRAM2 0x10000000 UNINIT 0x00010000 { ; Internal CCM SRAM
*(.ccm)
}
RW_RAM1 0xD0000000 UNINIT 0x00800000 { ; External SDRAM
*(HEAP)
}
}
*/
/* startup_stm32f429_439xx.s
...
Heap_Size EQU 0x00800000
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
...
*/
#include <
stdio.h
>
#include <
stdlib.h
>
#include ''stm32f429i_discovery.h''
#include ''stm32f429i_discovery_sdram.h''
/**************************************************************************************/
int main(void)
{
char *p;
/* Make sure to initialize the external memory, pins and buses before using them */
/* SDRAM Initialization */
SDRAM_Init();
/* Disable write protection */
FMC_SDRAMWriteProtectionConfig(FMC_Bank2_SDRAM,DISABLE);
p = malloc(0x1000);
printf(''Allocation at %p
'', p);
free(p);
while(1); // Don't want to exit
}
//******************************************************************************
// Hosting of stdio functionality through SWV - Serial Wire Viewer
//******************************************************************************
#include <
rt_misc.h
>
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
ITM_SendChar(ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
ch = '?';
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
ITM_SendChar(ch);
}
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d

'', file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
z1060
Associate II
Posted on November 21, 2014 at 10:35

Thank you very much

!

I use

in my project

as FreeRTOS. FreeRTOS

has its own heap.

/* Allocate the memory for the heap. */
static unsigned char ucHeap[ configTOTAL_HEAP_SIZE ];

Can

I

place

this

heap

on the

SDRAM? H

ow to do it

correctly

?
Posted on November 21, 2014 at 21:27

Probably

__attribute__((section(''HEAP''))) static unsigned char ucHeap[ configTOTAL_HEAP_SIZE ];

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..