From 65f1d8f4093073e7c76991417e5f2753ae8506c0 Mon Sep 17 00:00:00 2001 From: Xue Liu Date: Fri, 13 Nov 2015 13:39:40 +0100 Subject: [PATCH] Enable Heap for nRF51822 Fix the undefined symbol NRF_SRAM_END Configure SRAM part for Heap --- bsp/nrf51822/applications/startup.c | 8 ++++---- bsp/nrf51822/drivers/board.h | 6 ++++++ bsp/nrf51822/rtconfig.h | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bsp/nrf51822/applications/startup.c b/bsp/nrf51822/applications/startup.c index 04a245a033..660105ee48 100644 --- a/bsp/nrf51822/applications/startup.c +++ b/bsp/nrf51822/applications/startup.c @@ -28,13 +28,13 @@ extern int rt_application_init(void); #ifdef __CC_ARM extern int Image$$RW_IRAM1$$ZI$$Limit; -#define NRF_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) +#define NRF_HEAP_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) #elif __ICCARM__ #pragma section="HEAP" -#define NRF_SRAM_BEGIN (__segment_end("HEAP")) +#define NRF_HEAP_BEGIN (__segment_end("HEAP")) #else extern int __bss_end; -#define NRF_SRAM_BEGIN (&__bss_end) +#define NRF_HEAP_BEGIN (&__bss_end) #endif /** @@ -58,7 +58,7 @@ void rtthread_startup(void) rt_system_timer_init(); #ifdef RT_USING_HEAP - rt_system_heap_init((void*)NRF_SRAM_BEGIN, (void*)NRF_SRAM_END); + rt_system_heap_init((void*)NRF_HEAP_BEGIN, (void*)NRF_SRAM_END); #endif /* init scheduler system */ diff --git a/bsp/nrf51822/drivers/board.h b/bsp/nrf51822/drivers/board.h index e19ceb246e..3e793bc307 100644 --- a/bsp/nrf51822/drivers/board.h +++ b/bsp/nrf51822/drivers/board.h @@ -12,6 +12,12 @@ #ifndef __BOARD_H__ #define __BOARD_H__ +// Internal SRAM memory size[Kbytes] <16 or 32> +// Default: 16 +#define NRF_SRAM_BEGIN (0x20000000) +#define NRF_SRAM_SIZE (16 * 1024) +#define NRF_SRAM_END (NRF_SRAM_BEGIN + NRF_SRAM_SIZE) +//#endif void rt_hw_board_init(void); diff --git a/bsp/nrf51822/rtconfig.h b/bsp/nrf51822/rtconfig.h index b4df9066cb..8731f29c30 100644 --- a/bsp/nrf51822/rtconfig.h +++ b/bsp/nrf51822/rtconfig.h @@ -49,10 +49,10 @@ /* SECTION: Memory Management */ /* Using Memory Pool Management*/ -/* #define RT_USING_MEMPOOL */ +#define RT_USING_MEMPOOL /* Using Dynamic Heap Management */ -//#define RT_USING_HEAP +#define RT_USING_HEAP /* Using Small MM */ #define RT_USING_SMALL_MEM