diff --git a/bsp/stm32f7-disco/applications/application.c b/bsp/stm32f7-disco/applications/application.c index e1dafdf5b25b91466adf1127671c91dcde585cda..2bf527c90b2537d43c6d8a4089a70a8801be6d1a 100644 --- a/bsp/stm32f7-disco/applications/application.c +++ b/bsp/stm32f7-disco/applications/application.c @@ -24,14 +24,14 @@ */ #include -#include void rt_init_thread_entry(void *parameter) { - rt_components_init(); + //rt_components_init(); } -int rt_application_init() +//int rt_application_init() +int main(void) { rt_thread_t tid; diff --git a/bsp/stm32f7-disco/applications/startup.c b/bsp/stm32f7-disco/applications/startup.c deleted file mode 100644 index 628a805042092a63b532f4b7a2bd270a84ffee5d..0000000000000000000000000000000000000000 --- a/bsp/stm32f7-disco/applications/startup.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * File : startup.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015, RT-Thread Development Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Change Logs: - * Date Author Notes - * 2006-08-31 Bernard first implementation - * 2015-08-01 xiaonong modify for STM32F7 version - */ - -#include -#include -#include "board.h" - -#ifdef RT_USING_EXT_SDRAM -#include "drv_sdram.h" -#include "sram.h" -#endif - -/** - * @addtogroup STM32 - */ - -/*@{*/ - -extern int rt_application_init(void); - -#ifdef USE_FULL_ASSERT -/** -* @brief assert_failed -* 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\r\n", - file, line) */ - rt_kprintf("\n\r Wrong parameter value detected on\r\n"); - rt_kprintf(" file %s\r\n", file); - rt_kprintf(" line %d\r\n", line); - - /* Infinite loop */ - while (1) - {} -} -#endif - -/** - * This function will startup RT-Thread RTOS. - */ -void rtthread_startup(void) -{ - /* init board */ - rt_hw_board_init(); - - /* show version */ - rt_show_version(); - - /* init tick */ - rt_system_tick_init(); - - /* init kernel object */ - rt_system_object_init(); - - /* init timer system */ - rt_system_timer_init(); - -#ifdef RT_USING_EXT_SDRAM - sdram_hw_init(); - rt_system_heap_init((void*)EXT_SDRAM_BEGIN, (void*)EXT_SDRAM_END); - sram_init(); -#else - rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END); -#endif - - /* init scheduler system */ - rt_system_scheduler_init(); - - /* init application */ - rt_application_init(); - - /* init timer thread */ - rt_system_timer_thread_init(); - - /* init idle thread */ - rt_thread_idle_init(); - - /* start scheduler */ - rt_system_scheduler_start(); - - /* never reach here */ - return ; -} - -int main(void) -{ - /* disable interrupt first */ - rt_hw_interrupt_disable(); - - /* startup RT-Thread RTOS */ - rtthread_startup(); - - return 0; -} - -/*@}*/ diff --git a/bsp/stm32f7-disco/drivers/board.c b/bsp/stm32f7-disco/drivers/board.c index 734ecf2094d5783e93d36973957e6198072a202c..0553920a4706d3d168e64622cc995c0613f5e01e 100644 --- a/bsp/stm32f7-disco/drivers/board.c +++ b/bsp/stm32f7-disco/drivers/board.c @@ -22,13 +22,10 @@ * 2009-01-05 Bernard first implementation */ -#include #include -#include - #include "board.h" -#include "drv_usart.h" -#include "drv_mpu.h" +#include "sram.h" + /** * @addtogroup STM32 @@ -70,11 +67,11 @@ static void SystemClock_Config(void) RCC_OscInitStruct.PLL.PLLN = 400; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 8; - + ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); if(ret != HAL_OK) { - while(1) { ; } + while (1) { ; } } ret = HAL_PWREx_EnableOverDrive(); @@ -85,7 +82,8 @@ static void SystemClock_Config(void) /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ - RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |\ + RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; @@ -167,7 +165,7 @@ void HAL_ResumeTick(void) void rt_hw_board_init() { /* Configure the MPU attributes as Write Through */ - mpu_init(); + //mpu_init(); /* Enable the CPU Cache */ CPU_CACHE_Enable(); @@ -186,7 +184,16 @@ void rt_hw_board_init() /* set pend exception priority */ NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); +#ifdef RT_USING_COMPONENTS_INIT rt_components_board_init(); +#endif + +#ifdef RT_USING_EXT_SDRAM + rt_system_heap_init((void*)EXT_SDRAM_BEGIN, (void*)EXT_SDRAM_END); + sram_init(); +#else + rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END); +#endif #ifdef RT_USING_CONSOLE rt_console_set_device(RT_CONSOLE_DEVICE_NAME); diff --git a/bsp/stm32f7-disco/drivers/board.h b/bsp/stm32f7-disco/drivers/board.h index d4aebe06d6eb5443d394ab3d6e224304507e17ee..8d1e9f37397b1c0fc41e57944fddc82349fe7bb0 100644 --- a/bsp/stm32f7-disco/drivers/board.h +++ b/bsp/stm32f7-disco/drivers/board.h @@ -31,8 +31,8 @@ // Use external SDRAM memory on the board // Begin Address of External SDRAM #define EXT_SDRAM_BEGIN 0xC0000000 +// Size of External SDRAM #define EXT_SDRAM_SIZE (0x800000) -// End Address of External SDRAM #define EXT_SDRAM_END (EXT_SDRAM_BEGIN + EXT_SDRAM_SIZE) // diff --git a/bsp/stm32f7-disco/drivers/drv_mpu.c b/bsp/stm32f7-disco/drivers/drv_mpu.c index 4cab4d22818388cf4953920426dace65f6831ea9..630e48e2d2f62a76ff0432e0e0ba65ba5751e181 100644 --- a/bsp/stm32f7-disco/drivers/drv_mpu.c +++ b/bsp/stm32f7-disco/drivers/drv_mpu.c @@ -23,9 +23,9 @@ */ #include "drv_mpu.h" - - -void mpu_init(void) +#include +#include "stm32f7xx.h" +int mpu_init(void) { MPU_Region_InitTypeDef MPU_InitStruct; @@ -79,5 +79,6 @@ void mpu_init(void) /* Enable the MPU */ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); + return 0; } - +INIT_BOARD_EXPORT(mpu_init); diff --git a/bsp/stm32f7-disco/drivers/drv_mpu.h b/bsp/stm32f7-disco/drivers/drv_mpu.h index 707adfc2ef4286e2479a5d2403dd2e3d6f3b2eb3..9baf74b0d7330a42e36b7bede262eb902efac546 100644 --- a/bsp/stm32f7-disco/drivers/drv_mpu.h +++ b/bsp/stm32f7-disco/drivers/drv_mpu.h @@ -1,9 +1,9 @@ #ifndef __DRV_MPU_H #define __DRV_MPU_H -#include "stm32f7xx.h" + /* Initialize Cortex M MPU */ -void mpu_init(void); +int mpu_init(void); #endif diff --git a/bsp/stm32f7-disco/drivers/drv_sdram.c b/bsp/stm32f7-disco/drivers/drv_sdram.c index 4b58e21d01673880cefe09979c74d930bd8072b7..303bd3b9286f5185f8a73722adbf9b5dbfcd3d56 100644 --- a/bsp/stm32f7-disco/drivers/drv_sdram.c +++ b/bsp/stm32f7-disco/drivers/drv_sdram.c @@ -362,3 +362,9 @@ void SDRAM_DMA_IRQHandler(void) { HAL_DMA_IRQHandler(sdramHandle.hdma); } + +static int rt_sdram_hw_init(void) +{ + return (int)sdram_hw_init(); +} +INIT_BOARD_EXPORT(rt_sdram_hw_init); diff --git a/bsp/stm32f7-disco/rtconfig.h b/bsp/stm32f7-disco/rtconfig.h index bd0aaed397c1d039e9a35d2f510a27b6b7eff4fc..f599858171479d351e12d62428553a1fa87c1ff0 100644 --- a/bsp/stm32f7-disco/rtconfig.h +++ b/bsp/stm32f7-disco/rtconfig.h @@ -227,4 +227,7 @@ /* enable SDRAM */ #define RT_USING_EXT_SDRAM +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN + #endif diff --git a/bsp/stm32f7-disco/rtconfig.py b/bsp/stm32f7-disco/rtconfig.py index 91ef8db8b30185eb68e7a5371304d7f2633f68ce..8fd7dd90942dcd0f4de844363d3180e839dc3c33 100644 --- a/bsp/stm32f7-disco/rtconfig.py +++ b/bsp/stm32f7-disco/rtconfig.py @@ -45,7 +45,7 @@ if PLATFORM == 'gcc': STRIP = PREFIX + 'strip' DEVICE = ' -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -g -Wall -DSTM32F756xx -DUSE_HAL_DRIVER -D__ASSEMBLY__ -D__FPU_USED' + CFLAGS = DEVICE + ' -g -Wall -DSTM32F756xx -DUSE_HAL_DRIVER -D__ASSEMBLY__ -D__FPU_USED -eentry' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -lm -lgcc -lc' + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread_stm32f7xx.map,-cref,-u,Reset_Handler -T rtthread-stm32f7xx.ld'