diff --git a/bsp/stmsky001/board.c b/bsp/stmsky001/board.c index fb245eeac9..15d8e63311 100644 --- a/bsp/stmsky001/board.c +++ b/bsp/stmsky001/board.c @@ -133,6 +133,32 @@ void rt_hw_timer_handler(void) rt_interrupt_leave(); rt_hw_interrupt_thread_switch(); } + +static void FSMC_SRAM_Init(void) +{ +#define REG32(x) (*(volatile unsigned long*)(x)) + + /* enable FSMC clock */ + REG32(0x40021014) = 0x114; + + /* enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ + REG32(0x40021018) = 0x1e0; + + /* SRAM Data lines, NOE and NWE configuration */ + REG32(0x40011400) = 0x44BB44BB; + REG32(0x40011404) = 0xBBBBBBBB; + REG32(0x40011800) = 0xB44444BB; + REG32(0x40011804) = 0xBBBBBBBB; + REG32(0x40011C00) = 0x44BBBBBB; + REG32(0x40011C04) = 0xBBBB4444; + REG32(0x40012000) = 0x44BBBBBB; + REG32(0x40012004) = 0x44444B44; + + /* FSMC Configuration (enable FSMC Bank1_SRAM Bank) */ + REG32(0xA0000010) = 0x00001011; + REG32(0xA0000014) = 0x00000200; +} + /** * This function will initial STM32 board. @@ -147,6 +173,9 @@ void rt_hw_board_init() /* Configure the SysTick */ SysTick_Configuration(); + + /* Configure SRAM on the board */ + FSMC_SRAM_Init(); rt_hw_console_init(); } diff --git a/bsp/stmsky001/board.h b/bsp/stmsky001/board.h index b1be7c47ac..b11833bb50 100644 --- a/bsp/stmsky001/board.h +++ b/bsp/stmsky001/board.h @@ -14,6 +14,11 @@ #ifndef __BOARD_H__ #define __BOARD_H__ + +#define RT_USING_BOARD_SRAM + +#define BOARD_SRAM_BEGIN 0x68000000 +#define BOARD_SRAM_END 0x68080000 void rt_hw_board_led_on(int n); void rt_hw_board_led_off(int n); diff --git a/bsp/stmsky001/project.Uv2 b/bsp/stmsky001/project.Uv2 index 6b23e4e766..654b0627f7 100644 --- a/bsp/stmsky001/project.Uv2 +++ b/bsp/stmsky001/project.Uv2 @@ -1,7 +1,7 @@ ### uVision2 Project, (C) Keil Software ### Do not modify ! -Target (RT-Thread/STM32Sky), 0x0004 // Tools: 'ARM-ADS' +Target (RT-Thread/STMSky), 0x0004 // Tools: 'ARM-ADS' Group (Startup) Group (Library) @@ -78,7 +78,7 @@ File 5,1,<..\..\finsh\symbol.c> File 5,1,<..\..\finsh\cmd.c> -Options 1,0,0 // Target 'RT-Thread/STM32Sky' +Options 1,0,0 // Target 'RT-Thread/STMSky' Device (STM32F103ZE) Vendor (STMicroelectronics) Cpu (IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x807FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")) diff --git a/bsp/stmsky001/startup.c b/bsp/stmsky001/startup.c index e1caec079a..4a2092e750 100644 --- a/bsp/stmsky001/startup.c +++ b/bsp/stmsky001/startup.c @@ -34,7 +34,8 @@ extern void finsh_set_device(char* device); #endif extern int rt_application_init(void); - + +#ifndef RT_USING_BOARD_SRAM #ifdef __CC_ARM extern int Image$$RW_IRAM1$$ZI$$Limit; #elif __ICCARM__ @@ -42,6 +43,7 @@ extern int Image$$RW_IRAM1$$ZI$$Limit; #else extern int __bss_end; #endif +#endif #ifdef DEBUG /******************************************************************************* @@ -83,7 +85,10 @@ void rtthread_startup(void) /* init timer system */ rt_system_timer_init(); -#ifdef RT_USING_HEAP +#ifdef RT_USING_HEAP +#ifdef RT_USING_BOARD_SRAM + rt_system_heap_init((void*)BOARD_SRAM_BEGIN, (void*)BOARD_SRAM_END); +#else #ifdef __CC_ARM rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x20010000); #elif __ICCARM__ @@ -91,6 +96,7 @@ void rtthread_startup(void) #else /* init memory system */ rt_system_heap_init((void*)&__bss_end, (void*)0x20010000); +#endif #endif #endif