From a22b83c1339204bea7d4d32f0d233f6b1deb96f3 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 13 Feb 2015 17:05:51 +0800 Subject: [PATCH 01/11] Update README.md --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index ffd6c1bc2..5ed76e1b8 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,31 @@ As a special exception, including RT-Thread RTOS header files in a file, instant RT-Thread RTOS uses [scons](http://www.scons.org) as its building system. Therefore, please install scons and Python 2.7 firstly. +So far, the RT-Thread scons building system support the command line compiling or generate some IDE's project. There are some option varaibles in the scons building script: + +In rtconfig.py file: + +* ```RTT_CC``` the compiler which you want to use, gcc/keil/iar. +* ```EXEC_PATH``` the path of compiler. + +In SConstruct file: + +```RTT_ROOT``` This variable is the root directory of RT-Thread RTOS. If you build the porting in the bsp directory, you can use the default value. Also, you can set the root directory in ```RTT_ROOT``` environment variable. + +When you set these variables correctly, you can use command: + + scons + + under BSP directory to simplely compile RT-Thread RTOS. + +If you want to generate the IDE's project file, firstly you should change the ```RTT_CC``` in the rtconfig.py file. Then use command: + + scons --target=mdk/mdk4/iar/cb -s + +to generate the project file. + +NOTE: RT-Thread scons building system will tailor the system according to your rtconfig.h configuration header file. For example, if you disable the lwIP in the rtconfig.h by commenting the ```#define RT_USING_LWIP```, the generated project file has no lwIP related files. + ## Contribution ## Thank all of RT-Thread Developers. From 570e2ffbe74c20914e6942ecf6402b66ce61ac6b Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Mon, 23 Feb 2015 11:36:48 +0800 Subject: [PATCH 02/11] [finsh] Fix the echo mode issue. --- components/finsh/shell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 125dcec19..f28e235b3 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -526,7 +526,8 @@ void finsh_thread_entry(void* parameter) else { shell->line[shell->line_position] = ch; - rt_kprintf("%c", ch); + if (shell->echo_mode) + rt_kprintf("%c", ch); } ch = 0; From fbd620a7f4053f68cea82c67a0c7f515f1d02355 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Wed, 25 Feb 2015 10:50:21 +0800 Subject: [PATCH 03/11] [Kernel] Move the components initailzation to the kernel --- .../dfs/filesystems/skeleton/skeleton.c | 3 +- components/init/SConscript | 14 -- components/init/components.c | 177 ---------------- .../components.h => include/rtcomponents.h | 38 +--- src/init.c | 199 ++++++++++++++++++ 5 files changed, 207 insertions(+), 224 deletions(-) delete mode 100644 components/init/SConscript delete mode 100644 components/init/components.c rename components/init/components.h => include/rtcomponents.h (74%) create mode 100644 src/init.c diff --git a/components/dfs/filesystems/skeleton/skeleton.c b/components/dfs/filesystems/skeleton/skeleton.c index 74b015014..6abcec12f 100644 --- a/components/dfs/filesystems/skeleton/skeleton.c +++ b/components/dfs/filesystems/skeleton/skeleton.c @@ -1,7 +1,7 @@ /* * File : skeleton.c * This file is part of Device File System in RT-Thread RTOS - * COPYRIGHT (C) 2004-2011, RT-Thread Development Team + * COPYRIGHT (C) 2004-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 @@ -100,3 +100,4 @@ int dfs_skt_init(void) dfs_register(&_skt_fs); return 0; } +INIT_FS_EXPORT(dfs_skt_init); diff --git a/components/init/SConscript b/components/init/SConscript deleted file mode 100644 index 97e153524..000000000 --- a/components/init/SConscript +++ /dev/null @@ -1,14 +0,0 @@ -Import('rtconfig') -from building import * - -cwd = GetCurrentDir() -src = Glob('*.c') -CPPPATH = [cwd] -if rtconfig.CROSS_TOOL == 'keil': - LINKFLAGS = ' --keep __rt_init* ' -else: - LINKFLAGS = '' - -group = DefineGroup('Components', src, depend = ['RT_USING_COMPONENTS_INIT'], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) - -Return('group') diff --git a/components/init/components.c b/components/init/components.c deleted file mode 100644 index 2c507e12f..000000000 --- a/components/init/components.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * File : components.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2012 - 2013, 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 - * 2012-09-20 Bernard Change the name to components.c - * And all components related header files. - * 2012-12-23 Bernard fix the pthread initialization issue. - * 2013-06-23 Bernard Add the init_call for components initialization. - * 2013-07-05 Bernard Remove initialization feature for MS VC++ compiler - */ - -#include "components.h" - -static int rti_start(void) -{ - return 0; -} -INIT_EXPORT(rti_start, "0"); - -static int rti_board_end(void) -{ - return 0; -} -INIT_EXPORT(rti_board_end, "1.post"); - -static int rti_end(void) -{ - return 0; -} -INIT_EXPORT(rti_end,"7"); - -/** - * RT-Thread Components Initialization for board - */ -void rt_components_board_init(void) -{ -#ifndef _MSC_VER -#if RT_DEBUG_INIT - int result; - const struct rt_init_desc *desc; - for (desc = &__rt_init_desc_rti_start; desc < &__rt_init_desc_rti_board_end; desc ++) - { - rt_kprintf("initialize %s", desc->fn_name); - result = desc->fn(); - rt_kprintf(":%d done\n", result); - } -#else - const init_fn_t *fn_ptr; - - for (fn_ptr = &__rt_init_rti_start; fn_ptr < &__rt_init_rti_board_end; fn_ptr++) - { - (*fn_ptr)(); - } -#endif -#endif -} - -/** - * RT-Thread Components Initialization - */ -void rt_components_init(void) -{ -#ifndef _MSC_VER -#if RT_DEBUG_INIT - int result; - const struct rt_init_desc *desc; - - rt_kprintf("do components intialization.\n"); - for (desc = &__rt_init_desc_rti_board_end; desc < &__rt_init_desc_rti_end; desc ++) - { - rt_kprintf("initialize %s", desc->fn_name); - result = desc->fn(); - rt_kprintf(":%d done\n", result); - } -#else - const init_fn_t *fn_ptr; - - for (fn_ptr = &__rt_init_rti_board_end; fn_ptr < &__rt_init_rti_end; fn_ptr ++) - { - (*fn_ptr)(); - } -#endif -#else -#ifdef RT_USING_MODULE - rt_system_module_init(); -#endif - -#ifdef RT_USING_FINSH - /* initialize finsh */ - finsh_system_init(); - finsh_set_device(RT_CONSOLE_DEVICE_NAME); -#endif - -#ifdef RT_USING_LWIP - /* initialize lwip stack */ - /* register ethernetif device */ - eth_system_device_init(); - - /* initialize lwip system */ - lwip_system_init(); - rt_kprintf("TCP/IP initialized!\n"); -#endif - -#ifdef RT_USING_DFS - /* initialize the device file system */ - dfs_init(); - -#ifdef RT_USING_DFS_ELMFAT - /* initialize the elm chan FatFS file system*/ - elm_init(); -#endif - -#if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) - /* initialize NFSv3 client file system */ - nfs_init(); -#endif - -#ifdef RT_USING_DFS_YAFFS2 - dfs_yaffs2_init(); -#endif - -#ifdef RT_USING_DFS_UFFS - dfs_uffs_init(); -#endif - -#ifdef RT_USING_DFS_JFFS2 - dfs_jffs2_init(); -#endif - -#ifdef RT_USING_DFS_ROMFS - dfs_romfs_init(); -#endif - -#ifdef RT_USING_DFS_RAMFS - dfs_ramfs_init(); -#endif - -#ifdef RT_USING_DFS_DEVFS - devfs_init(); -#endif -#endif /* end of RT_USING_DFS */ - -#ifdef RT_USING_NEWLIB - libc_system_init(RT_CONSOLE_DEVICE_NAME); -#else - /* the pthread system initialization will be initiallized in libc */ -#ifdef RT_USING_PTHREADS - pthread_system_init(); -#endif -#endif - -#ifdef RT_USING_RTGUI - rtgui_system_server_init(); -#endif - -#ifdef RT_USING_USB_HOST - rt_usb_host_init(); -#endif -#endif -} diff --git a/components/init/components.h b/include/rtcomponents.h similarity index 74% rename from components/init/components.h rename to include/rtcomponents.h index 11d3c8178..70accb99d 100644 --- a/components/init/components.h +++ b/include/rtcomponents.h @@ -1,7 +1,8 @@ /* - * File : components_init.h + * File : rtcomponents.h + * header for RT-Thread components * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2012, RT-Thread Development Team + * COPYRIGHT (C) 2012-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 @@ -21,12 +22,11 @@ * Date Author Notes * 2012-09-20 Bernard Change the name to components.h * And all components related header files. + * 2015-02-06 Bernard Rename the components.h to rtcom.h */ -#ifndef __COMPONENTS_INIT_H__ -#define __COMPONENTS_INIT_H__ - -#include +#ifndef RTCOM_H__ +#define RTCOM_H__ #ifdef RT_USING_FINSH #include @@ -36,7 +36,6 @@ #ifdef RT_USING_LWIP #include #include -extern void lwip_system_init(void); #endif #ifdef RT_USING_DFS @@ -68,9 +67,6 @@ extern void lwip_system_init(void); #endif #endif -#ifdef RT_USING_NEWLIB -#include -#endif #ifdef RT_USING_PTHREADS #include #endif @@ -79,27 +75,5 @@ extern void lwip_system_init(void); #include #endif -#ifdef RT_USING_RTGUI -#include #endif -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Initializes board routine in RT-Thread. - */ -void rt_components_board_init(void); - -/** - * Initializes components in RT-Thread - * notes: this function must be invoked in Init Thread - */ -void rt_components_init(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/init.c b/src/init.c new file mode 100644 index 000000000..3b95ea3a5 --- /dev/null +++ b/src/init.c @@ -0,0 +1,199 @@ +/* + * File : init.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2012 - 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 + * 2012-09-20 Bernard Change the name to components.c + * And all components related header files. + * 2012-12-23 Bernard fix the pthread initialization issue. + * 2013-06-23 Bernard Add the init_call for components initialization. + * 2013-07-05 Bernard Remove initialization feature for MS VC++ compiler + * 2015-02-06 Bernard Remove the MS VC++ support and move to the kernel + */ + +#include + +#ifdef RT_USING_COMPONENTS_INIT +/* + * Components Initialization will initialize some driver and components as following + * order: + * rti_start --> 0 + * BOARD_EXPORT --> 1 + * rti_board_end --> 1.end + * + * DEVICE_EXPORT --> 2 + * COMPONENT_EXPORT --> 3 + * FS_EXPORT --> 4 + * ENV_EXPORT --> 5 + * APP_EXPORT --> 6 + * + * rti_end --> 6.end + * + * These automatically initializaiton, the driver or component initial function must + * be defined with: + * INIT_BOARD_EXPORT(fn); + * INIT_DEVICE_EXPORT(fn); + * ... + * INIT_APP_EXPORT(fn); + * etc. + */ +static int rti_start(void) +{ + return 0; +} +INIT_EXPORT(rti_start, "0"); + +static int rti_board_end(void) +{ + return 0; +} +INIT_EXPORT(rti_board_end, "1.end"); + +static int rti_end(void) +{ + return 0; +} +INIT_EXPORT(rti_end, "6.end"); + +/** + * RT-Thread Components Initialization for board + */ +void rt_components_board_init(void) +{ +#if RT_DEBUG_INIT + int result; + const struct rt_init_desc *desc; + for (desc = &__rt_init_desc_rti_start; desc < &__rt_init_desc_rti_board_end; desc ++) + { + rt_kprintf("initialize %s", desc->fn_name); + result = desc->fn(); + rt_kprintf(":%d done\n", result); + } +#else + const init_fn_t *fn_ptr; + + for (fn_ptr = &__rt_init_rti_start; fn_ptr < &__rt_init_rti_board_end; fn_ptr++) + { + (*fn_ptr)(); + } +#endif +} + +/** + * RT-Thread Components Initialization + */ +void rt_components_init(void) +{ +#if RT_DEBUG_INIT + int result; + const struct rt_init_desc *desc; + + rt_kprintf("do components intialization.\n"); + for (desc = &__rt_init_desc_rti_board_end; desc < &__rt_init_desc_rti_end; desc ++) + { + rt_kprintf("initialize %s", desc->fn_name); + result = desc->fn(); + rt_kprintf(":%d done\n", result); + } +#else + const init_fn_t *fn_ptr; + + for (fn_ptr = &__rt_init_rti_board_end; fn_ptr < &__rt_init_rti_end; fn_ptr ++) + { + (*fn_ptr)(); + } +#endif +} + +#ifdef RT_USING_USER_MAIN +void rt_application_init(void); +void rt_hw_board_init(void); + +#ifndef RT_USING_HEAP +/* if there is not enble heap, we should use static thread and stack. */ +ALIGN(8) +static rt_uint8_t main_stack[2048]; +struct rt_thread main_thread; +#endif + +/* the system main thread */ +void main_thread_entry(void *parameter) +{ + extern int main(void); + + /* RT-Thread components initialization */ + rt_components_init(); + + /* invoke system main function */ + main(); +} + +void rt_application_init(void) +{ + rt_thread_t tid; + +#ifdef RT_USING_HEAP + tid = rt_thread_create("main", main_thread_entry, RT_NULL, + 2048, RT_THREAD_PRIORITY_MAX / 3, 20); + RT_ASSERT(tid != RT_NULL); +#else + rt_err_t result; + + tid = &main_thread; + result = rt_thread_init(tid, "main", main_thread_entry, RT_NULL, + 2048, RT_THREAD_PRIORITY_MAX / 3, 20); + RT_ASSERT(result != RT_EOK); +#endif + + rt_thread_startup(tid); +} + +int rtthread_startup(void) +{ + /* board level initalization + * NOTE: please initialize heap inside board initialization. + */ + rt_hw_board_init(); + + /* show RT-Thread version */ + rt_show_version(); + + /* timer system initialization */ + rt_system_timer_init(); + + /* scheduler system initialization */ + rt_system_scheduler_init(); + + /* create init_thread */ + rt_application_init(); + + /* timer thread initialization */ + rt_system_timer_thread_init(); + + /* idle thread initialization */ + rt_thread_idle_init(); + + /* start scheduler */ + rt_system_scheduler_start(); + + /* never reach here */ + return ; +} +#endif +#endif From 924264b277a2c01fed27d051d9e6a3913e0de975 Mon Sep 17 00:00:00 2001 From: bernard Date: Fri, 20 Mar 2015 12:44:02 +0800 Subject: [PATCH 04/11] Remove list_mod_detail command from msh. --- components/finsh/cmd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c index e449e0c2d..7d24a33d6 100644 --- a/components/finsh/cmd.c +++ b/components/finsh/cmd.c @@ -623,7 +623,6 @@ int list_mod_detail(const char *name) return 0; } FINSH_FUNCTION_EXPORT(list_mod_detail, list module objects in system) -MSH_CMD_EXPORT(list_mod_detail, list module objects in system) #endif long list(void) From 5b1270455d6700e21c043f2cd5794fc0f88618ae Mon Sep 17 00:00:00 2001 From: bernard Date: Fri, 20 Mar 2015 12:44:58 +0800 Subject: [PATCH 05/11] Fix the echo issue in the shell. --- components/finsh/shell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 125dcec19..f28e235b3 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -526,7 +526,8 @@ void finsh_thread_entry(void* parameter) else { shell->line[shell->line_position] = ch; - rt_kprintf("%c", ch); + if (shell->echo_mode) + rt_kprintf("%c", ch); } ch = 0; From cf37bccae40a364bc99ce648c286096eb51abe81 Mon Sep 17 00:00:00 2001 From: "Bernard.Xiong" Date: Sun, 22 Mar 2015 08:56:37 +0800 Subject: [PATCH 06/11] Add copyright information --- components/cplusplus/crt.cpp | 24 ++++++++++++++++++++++++ components/cplusplus/crt.h | 24 ++++++++++++++++++++++++ components/cplusplus/crt_init.c | 2 +- tools/wizard.py | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/components/cplusplus/crt.cpp b/components/cplusplus/crt.cpp index 6fa540b9e..b6455f73f 100644 --- a/components/cplusplus/crt.cpp +++ b/components/cplusplus/crt.cpp @@ -1,3 +1,27 @@ +/* +* File : crt.cpp +* This file is part of Device File System in RT-Thread RTOS +* COPYRIGHT (C) 2008-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 +* 2015-03-07 Bernard Add copyright header. +*/ + #include #include "crt.h" diff --git a/components/cplusplus/crt.h b/components/cplusplus/crt.h index fd287c2ad..105aa0e4f 100644 --- a/components/cplusplus/crt.h +++ b/components/cplusplus/crt.h @@ -1,3 +1,27 @@ +/* +* File : crt.h +* This file is part of Device File System in RT-Thread RTOS +* COPYRIGHT (C) 2008-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 +* 2015-03-07 Bernard Add copyright header. +*/ + #ifndef CRT_H_ #define CRT_H_ diff --git a/components/cplusplus/crt_init.c b/components/cplusplus/crt_init.c index 958177c1f..9a823e394 100644 --- a/components/cplusplus/crt_init.c +++ b/components/cplusplus/crt_init.c @@ -1,7 +1,7 @@ /* * File : crt_init.c * This file is part of Device File System in RT-Thread RTOS -* COPYRIGHT (C) 2008-2011, RT-Thread Development Team +* COPYRIGHT (C) 2008-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 diff --git a/tools/wizard.py b/tools/wizard.py index 41e90775d..d32f116a9 100755 --- a/tools/wizard.py +++ b/tools/wizard.py @@ -40,7 +40,7 @@ SConscript_com = '''# RT-Thread building script for component from building import * cwd = GetCurrentDir() -src = Glob('*.c') +src = Glob('*.c') + Glob('*.cpp') CPPPATH = [cwd] group = DefineGroup('COMPONENT_NAME', src, depend = [''], CPPPATH = CPPPATH) From 62a0172d11e559272128bf52b56ef806ba28ae24 Mon Sep 17 00:00:00 2001 From: "Bernard.Xiong" Date: Sun, 22 Mar 2015 09:06:48 +0800 Subject: [PATCH 07/11] [Kernel] Fix the system initialization link issue --- include/components.h | 79 ++++++++++++++++++++++++++++++++++++++++++++ include/rtthread.h | 13 +++++--- src/SConscript | 9 +++-- 3 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 include/components.h diff --git a/include/components.h b/include/components.h new file mode 100644 index 000000000..4113a8691 --- /dev/null +++ b/include/components.h @@ -0,0 +1,79 @@ +/* + * File : components.h + * header for RT-Thread components + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2012-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 + * 2012-09-20 Bernard Change the name to components.h + * And all components related header files. + * 2015-02-06 Bernard Rename the components.h to rtcom.h + * 2015-03-22 Bernard Keep the compatibility. + */ + +#ifndef COMPONENTS_H__ +#define COMPONENTS_H__ + +#ifdef RT_USING_FINSH +#include +#include +#endif + +#ifdef RT_USING_LWIP +#include +#include +#endif + +#ifdef RT_USING_DFS +#include +#include +#ifdef RT_USING_DFS_ELMFAT +#include +#endif +#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS) +#include +#endif +#ifdef RT_USING_DFS_ROMFS +#include +#endif +#ifdef RT_USING_DFS_DEVFS +#include +#endif +#ifdef RT_USING_DFS_UFFS +#include +#endif +#ifdef RT_USING_DFS_JFFS2 +#include +#endif +#ifdef RT_USING_DFS_YAFFS2 +#include +#endif +#ifdef RT_USING_DFS_ROMFS +#include +#endif +#endif + +#ifdef RT_USING_PTHREADS +#include +#endif + +#ifdef RT_USING_MODULE +#include +#endif + +#endif diff --git a/include/rtthread.h b/include/rtthread.h index edd207bcb..5309c31d5 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -437,6 +437,11 @@ void rt_module_unload_sethook(void (*hook)(rt_module_t module)); void rt_module_init_object_container(struct rt_module *module); rt_err_t rt_module_destroy(rt_module_t module); +/* + * application module system initialization + */ +int rt_system_module_init(void); + /*@}*/ #endif @@ -455,10 +460,10 @@ void rt_interrupt_leave(void); */ rt_uint8_t rt_interrupt_get_nest(void); -/** - * application module - */ -int rt_system_module_init(void); +#ifdef RT_USING_COMPONENTS_INIT +void rt_components_init(void); +void rt_components_board_init(void); +#endif /** * @addtogroup KernelService diff --git a/src/SConscript b/src/SConscript index 0eda61b1e..6d5936519 100644 --- a/src/SConscript +++ b/src/SConscript @@ -5,8 +5,13 @@ from building import * src = Glob('*.c') CPPPATH = [RTT_ROOT + '/include'] -if rtconfig.CROSS_TOOL == 'keil' and GetDepend('RT_USING_MODULE') == True: - LINKFLAGS = ' --keep __rtmsym_* ' +if rtconfig.CROSS_TOOL == 'keil': + # add more link flags for module and components_init. + LINKFLAGS = '' + if GetDepend('RT_USING_MODULE'): + LINKFLAGS = ' --keep __rtmsym_* ' + if GetDepend('RT_USING_COMPONENTS_INIT'): + LINKFLAGS = ' --keep __rt_init* ' else: LINKFLAGS = '' From 0da8d515acb23f702deaa6d6ee332a225d2bdb48 Mon Sep 17 00:00:00 2001 From: "Bernard.Xiong" Date: Thu, 26 Mar 2015 19:58:05 +0800 Subject: [PATCH 08/11] [Libc] Change libc_system_init as INIT_COMPONENT --- components/libc/newlib/libc.c | 36 ++++++++++++++++++++--------------- components/libc/newlib/libc.h | 14 +++++++------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/components/libc/newlib/libc.c b/components/libc/newlib/libc.c index 73270969b..0427a6d91 100644 --- a/components/libc/newlib/libc.c +++ b/components/libc/newlib/libc.c @@ -18,32 +18,38 @@ #endif -void libc_system_init(const char* tty_name) +int libc_system_init(void) { #ifdef RT_USING_DFS - int fd; + int fd; + struct rt_device *console_dev; #ifndef RT_USING_DFS_DEVFS #error Please enable devfs by defining RT_USING_DFS_DEVFS in rtconfig.h #endif - /* initialize console device */ - rt_console_init(tty_name); + console_dev = rt_console_get_device(); + if (console_dev) + { + /* initialize console device */ + rt_console_init(console_dev->parent.name); - /* open console as stdin/stdout/stderr */ - fd = open("/dev/console", O_RDONLY, 0); /* for stdin */ - fd = open("/dev/console", O_WRONLY, 0); /* for stdout */ - fd = open("/dev/console", O_WRONLY, 0); /* for stderr */ - - /* skip warning */ - fd = fd; + /* open console as stdin/stdout/stderr */ + fd = open("/dev/console", O_RDONLY, 0); /* for stdin */ + fd = open("/dev/console", O_WRONLY, 0); /* for stdout */ + fd = open("/dev/console", O_WRONLY, 0); /* for stderr */ + + /* skip warning */ + fd = fd; + } #endif - /* set PATH and HOME */ - putenv("PATH=/"); - putenv("HOME=/"); + /* set PATH and HOME */ + putenv("PATH=/bin"); + putenv("HOME=/home"); #ifdef RT_USING_PTHREADS - pthread_system_init(); + pthread_system_init(); #endif } +INIT_COMPONENT_EXPORT(libc_system_init); diff --git a/components/libc/newlib/libc.h b/components/libc/newlib/libc.h index 52fddd949..a4f342df3 100644 --- a/components/libc/newlib/libc.h +++ b/components/libc/newlib/libc.h @@ -3,15 +3,15 @@ #include -#define MILLISECOND_PER_SECOND 1000UL -#define MICROSECOND_PER_SECOND 1000000UL -#define NANOSECOND_PER_SECOND 1000000000UL +#define MILLISECOND_PER_SECOND 1000UL +#define MICROSECOND_PER_SECOND 1000000UL +#define NANOSECOND_PER_SECOND 1000000000UL -#define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND) -#define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND) -#define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND) +#define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND) +#define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND) +#define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND) -void libc_system_init(const char* tty_name); +int libc_system_init(void); /* some time related function */ int libc_set_time(const struct timespec *time); From 1377022b1873b9befb2b0819b6e6d1e3718b2b43 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 3 Apr 2015 14:26:18 +0000 Subject: [PATCH 09/11] [DFS] Use SConscript of each file system to build. --- components/dfs/SConscript | 211 +------------------ components/dfs/filesystems/SConscript | 15 ++ components/dfs/filesystems/devfs/SConscript | 11 + components/dfs/filesystems/elmfat/SConscript | 26 +++ components/dfs/filesystems/jffs2/SConscript | 50 +++++ components/dfs/filesystems/nfs/SConscript | 11 + components/dfs/filesystems/ramfs/SConscript | 2 +- components/dfs/filesystems/romfs/SConscript | 15 ++ components/dfs/filesystems/uffs/SConscript | 11 + include/rtcomponents.h | 79 ------- 10 files changed, 151 insertions(+), 280 deletions(-) create mode 100644 components/dfs/filesystems/SConscript create mode 100644 components/dfs/filesystems/devfs/SConscript create mode 100644 components/dfs/filesystems/elmfat/SConscript create mode 100644 components/dfs/filesystems/jffs2/SConscript create mode 100644 components/dfs/filesystems/nfs/SConscript create mode 100644 components/dfs/filesystems/romfs/SConscript create mode 100644 components/dfs/filesystems/uffs/SConscript delete mode 100644 include/rtcomponents.h diff --git a/components/dfs/SConscript b/components/dfs/SConscript index 132f237f8..e13ed292d 100644 --- a/components/dfs/SConscript +++ b/components/dfs/SConscript @@ -1,207 +1,18 @@ -Import('RTT_ROOT') -Import('rtconfig') from building import * # The set of source files associated with this SConscript file. -dfs = Split(""" -src/dfs.c -src/dfs_fs.c -src/dfs_file.c -src/dfs_posix.c -""") +src = Glob('src/*.c') +cwd = GetCurrentDir() +CPPPATH = [cwd + "/include"] -# DFS-ELMFAT options -elmfat = Split(""" -filesystems/elmfat/dfs_elm.c -filesystems/elmfat/ff.c -""") +group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS'], CPPPATH = CPPPATH) -# DFS-ROMFS options -romfs = Split(""" -filesystems/romfs/dfs_romfs.c -""") -if not GetDepend('DFS_ROMFS_ROOT'): - romfs = romfs + Split('filesystems/romfs/romfs.c') - -# DFS-RAMFS options -ramfs = Split(""" -filesystems/ramfs/dfs_ramfs.c -""") - -# DFS-DeviceFS options -devfs = Split(""" -filesystems/devfs/devfs.c -filesystems/devfs/console.c -""") - -# DFS-YAFFS2 options -yaffs2_src = Split(""" -filesystems/yaffs2/dfs_yaffs2.c -filesystems/yaffs2/yaffs_osglue.c -filesystems/yaffs2/yaffs_nandcfg.c - -filesystems/yaffs2/yaffs/yaffs_allocator.c -filesystems/yaffs2/yaffs/yaffs_bitmap.c -filesystems/yaffs2/yaffs/yaffs_checkptrw.c -filesystems/yaffs2/yaffs/yaffs_ecc.c -filesystems/yaffs2/yaffs/yaffs_guts.c -filesystems/yaffs2/yaffs/yaffs_nameval.c -filesystems/yaffs2/yaffs/yaffs_nand.c -filesystems/yaffs2/yaffs/yaffs_packedtags1.c -filesystems/yaffs2/yaffs/yaffs_packedtags2.c -filesystems/yaffs2/yaffs/yaffs_summary.c -filesystems/yaffs2/yaffs/yaffs_tagscompat.c -filesystems/yaffs2/yaffs/yaffs_verify.c -filesystems/yaffs2/yaffs/yaffs_yaffs1.c -filesystems/yaffs2/yaffs/yaffs_yaffs2.c - -filesystems/yaffs2/yaffs/direct/yaffs_attribs.c -filesystems/yaffs2/yaffs/direct/yaffs_hweight.c -filesystems/yaffs2/yaffs/direct/yaffs_nandif.c -filesystems/yaffs2/yaffs/direct/yaffs_qsort.c -filesystems/yaffs2/yaffs/direct/yaffsfs.c - -""") - -nfs = Split(''' -filesystems/nfs/mount_clnt.c -filesystems/nfs/mount_xdr.c -filesystems/nfs/nfs_clnt.c -filesystems/nfs/nfs_xdr.c -filesystems/nfs/dfs_nfs.c -filesystems/nfs/rpc/auth_none.c -filesystems/nfs/rpc/clnt_generic.c -filesystems/nfs/rpc/clnt_udp.c -filesystems/nfs/rpc/rpc_prot.c -filesystems/nfs/rpc/pmap.c -filesystems/nfs/rpc/xdr.c -filesystems/nfs/rpc/xdr_mem.c -''') - -uffs = Split(''' -filesystems/uffs/src/uffs/uffs_badblock.c -filesystems/uffs/src/uffs/uffs_blockinfo.c -filesystems/uffs/src/uffs/uffs_buf.c -filesystems/uffs/src/uffs/uffs_debug.c -filesystems/uffs/src/uffs/uffs_device.c -filesystems/uffs/src/uffs/uffs_ecc.c -filesystems/uffs/src/uffs/uffs_crc.c -filesystems/uffs/src/uffs/uffs_fd.c -filesystems/uffs/src/uffs/uffs_find.c -filesystems/uffs/src/uffs/uffs_flash.c -filesystems/uffs/src/uffs/uffs_fs.c -filesystems/uffs/src/uffs/uffs_init.c -filesystems/uffs/src/uffs/uffs_mem.c -filesystems/uffs/src/uffs/uffs_mtb.c -filesystems/uffs/src/uffs/uffs_pool.c -filesystems/uffs/src/uffs/uffs_public.c -filesystems/uffs/src/uffs/uffs_tree.c -filesystems/uffs/src/uffs/uffs_utils.c -filesystems/uffs/src/uffs/uffs_version.c - -filesystems/uffs/dfs_uffs.c -filesystems/uffs/uffs_nandif.c -filesystems/uffs/uffs_rtthread.c -''') - -jffs2 = Split(''' -filesystems/jffs2/dfs_jffs2.c -filesystems/jffs2/porting.c - -filesystems/jffs2/cyg/compress/src/adler32.c -filesystems/jffs2/cyg/compress/src/compress.c -filesystems/jffs2/cyg/compress/src/deflate.c -filesystems/jffs2/cyg/compress/src/infback.c -filesystems/jffs2/cyg/compress/src/inffast.c -filesystems/jffs2/cyg/compress/src/inflate.c -filesystems/jffs2/cyg/compress/src/inftrees.c -filesystems/jffs2/cyg/compress/src/trees.c -filesystems/jffs2/cyg/compress/src/uncompr.c -filesystems/jffs2/cyg/compress/src/zutil.c - -filesystems/jffs2/cyg/crc/crc16.c -filesystems/jffs2/cyg/crc/crc32.c -filesystems/jffs2/cyg/crc/posix_crc.c -filesystems/jffs2/kernel/rbtree.c -filesystems/jffs2/src/build.c -filesystems/jffs2/src/compr.c -filesystems/jffs2/src/compr_rtime.c -filesystems/jffs2/src/compr_rubin.c -filesystems/jffs2/src/compr_zlib.c -filesystems/jffs2/src/debug.c -filesystems/jffs2/src/dir-ecos.c -filesystems/jffs2/src/erase.c -filesystems/jffs2/src/flashio.c -filesystems/jffs2/src/fs-ecos.c -filesystems/jffs2/src/gc.c -filesystems/jffs2/src/gcthread.c -filesystems/jffs2/src/malloc-ecos.c -filesystems/jffs2/src/nodelist.c -filesystems/jffs2/src/nodemgmt.c -filesystems/jffs2/src/read.c -filesystems/jffs2/src/readinode.c -filesystems/jffs2/src/scan.c -filesystems/jffs2/src/write.c -''') - -src_local = dfs -CPPDEFINES = [] - -# The set of source files associated with this SConscript file. -path = [RTT_ROOT + '/components/dfs', RTT_ROOT + '/components/dfs/include'] - -if GetDepend('RT_USING_DFS_YAFFS2'): - src_local = src_local + yaffs2_src - path = path + [RTT_ROOT + '/components/dfs/filesystems/yaffs2/yaffs', \ - RTT_ROOT + '/components/dfs/filesystems/yaffs2/yaffs/direct' ] - -if GetDepend('RT_USING_DFS_ELMFAT'): - if GetDepend('RT_DFS_ELM_USE_LFN'): - if GetDepend('RT_DFS_ELM_CODE_PAGE_FILE'): - elmfat += ['filesystems/elmfat/option/ccfile.c'] - else: - if GetConfigValue('RT_DFS_ELM_CODE_PAGE') == 932: - elmfat += ['filesystems/elmfat/option/cc932.c'] - elif GetConfigValue('RT_DFS_ELM_CODE_PAGE') == 936: - elmfat += ['filesystems/elmfat/option/cc936.c'] - elif GetConfigValue('RT_DFS_ELM_CODE_PAGE') == 949: - elmfat += ['filesystems/elmfat/option/cc949.c'] - elif GetConfigValue('RT_DFS_ELM_CODE_PAGE') == 950: - elmfat += ['filesystems/elmfat/option/cc950.c'] - else: - elmfat += ['filesystems/elmfat/option/ccsbcs.c'] - src_local = src_local + elmfat - -if GetDepend(['RT_USING_DFS_NFS', 'RT_USING_LWIP']): - src_local = src_local + nfs - path = path + [RTT_ROOT + '/components/dfs/filesystems/nfs'] - -if GetDepend('RT_USING_DFS_ROMFS'): - src_local = src_local + romfs - path = path + [RTT_ROOT + '/components/dfs/filesystems/romfs'] - -if GetDepend('RT_USING_DFS_RAMFS'): - src_local = src_local + ramfs - path = path + [RTT_ROOT + '/components/dfs/filesystems/ramfs'] - -if GetDepend('RT_USING_DFS_DEVFS'): - src_local = src_local + devfs - path = path + [RTT_ROOT + '/components/dfs/filesystems/devfs'] - -if GetDepend('RT_USING_DFS_UFFS'): - src_local = src_local + uffs - path = path + [RTT_ROOT + '/components/dfs/filesystems/uffs/src/inc', \ - RTT_ROOT + '/components/dfs/filesystems/uffs'] #, \ - # RTT_ROOT + '/components/dfs/filesystems/uffs/flash'] - -if GetDepend('RT_USING_DFS_JFFS2'): - src_local = src_local + jffs2 - path = path + [RTT_ROOT + '/components/dfs/filesystems/jffs2/src', \ - RTT_ROOT + '/components/dfs/filesystems/jffs2/kernel', \ - RTT_ROOT + '/components/dfs/filesystems/jffs2/include', \ - RTT_ROOT + '/components/dfs/filesystems/jffs2', \ - RTT_ROOT + '/components/dfs/filesystems/jffs2/cyg/compress'] - -group = DefineGroup('Filesystem', src_local, depend = ['RT_USING_DFS'], CPPPATH = path, CPPDEFINES = CPPDEFINES) +if GetDepend('RT_USING_DFS'): + # search in the file system implementation + list = os.listdir(cwd) + + for item in list: + if os.path.isfile(os.path.join(cwd, item, 'SConscript')): + group = group + SConscript(os.path.join(item, 'SConscript')) Return('group') diff --git a/components/dfs/filesystems/SConscript b/components/dfs/filesystems/SConscript new file mode 100644 index 000000000..4c815c49b --- /dev/null +++ b/components/dfs/filesystems/SConscript @@ -0,0 +1,15 @@ +# RT-Thread building script for bridge + +import os +from building import * + +cwd = GetCurrentDir() +objs = [] +list = os.listdir(cwd) + +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(d, 'SConscript')) + +Return('objs') diff --git a/components/dfs/filesystems/devfs/SConscript b/components/dfs/filesystems/devfs/SConscript new file mode 100644 index 000000000..898b04a23 --- /dev/null +++ b/components/dfs/filesystems/devfs/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') +CPPPATH = [cwd] + +group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_DEVFS'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/dfs/filesystems/elmfat/SConscript b/components/dfs/filesystems/elmfat/SConscript new file mode 100644 index 000000000..8b7ec02d4 --- /dev/null +++ b/components/dfs/filesystems/elmfat/SConscript @@ -0,0 +1,26 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') +CPPPATH = [cwd] + +if GetDepend('RT_DFS_ELM_USE_LFN'): + if GetDepend('RT_DFS_ELM_CODE_PAGE_FILE'): + src += ['option/ccfile.c'] + else: + if GetConfigValue('RT_DFS_ELM_CODE_PAGE') == 932: + src += ['option/cc932.c'] + elif GetConfigValue('RT_DFS_ELM_CODE_PAGE') == 936: + src += ['option/cc936.c'] + elif GetConfigValue('RT_DFS_ELM_CODE_PAGE') == 949: + src += ['option/cc949.c'] + elif GetConfigValue('RT_DFS_ELM_CODE_PAGE') == 950: + src += ['option/cc950.c'] + else: + src += ['option/ccsbcs.c'] + +group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_ELMFAT'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/dfs/filesystems/jffs2/SConscript b/components/dfs/filesystems/jffs2/SConscript new file mode 100644 index 000000000..47854393e --- /dev/null +++ b/components/dfs/filesystems/jffs2/SConscript @@ -0,0 +1,50 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Split(''' +dfs_jffs2.c +porting.c + +cyg/compress/src/adler32.c +cyg/compress/src/compress.c +cyg/compress/src/deflate.c +cyg/compress/src/infback.c +cyg/compress/src/inffast.c +cyg/compress/src/inflate.c +cyg/compress/src/inftrees.c +cyg/compress/src/trees.c +cyg/compress/src/uncompr.c +cyg/compress/src/zutil.c + +cyg/crc/crc16.c +cyg/crc/crc32.c +cyg/crc/posix_crc.c +kernel/rbtree.c +src/build.c +src/compr.c +src/compr_rtime.c +src/compr_rubin.c +src/compr_zlib.c +src/debug.c +src/dir-ecos.c +src/erase.c +src/flashio.c +src/fs-ecos.c +src/gc.c +src/gcthread.c +src/malloc-ecos.c +src/nodelist.c +src/nodemgmt.c +src/read.c +src/readinode.c +src/scan.c +src/write.c +''') + +CPPPATH = [cwd, cwd + '/include', cwd + '/src', cwd + '/cyg', cwd + '/kernel', cwd + '/cyg/compress'] + +group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_JFFS2'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/dfs/filesystems/nfs/SConscript b/components/dfs/filesystems/nfs/SConscript new file mode 100644 index 000000000..3a5a665b3 --- /dev/null +++ b/components/dfs/filesystems/nfs/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') +CPPPATH = [cwd] + +group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_NFS'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/dfs/filesystems/ramfs/SConscript b/components/dfs/filesystems/ramfs/SConscript index 637ee2d9b..1304f5962 100644 --- a/components/dfs/filesystems/ramfs/SConscript +++ b/components/dfs/filesystems/ramfs/SConscript @@ -4,6 +4,6 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_MEMHEAP'], CPPPATH = CPPPATH) +group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_MEMHEAP', 'RT_USING_DFS_RAMFS'], CPPPATH = CPPPATH) Return('group') diff --git a/components/dfs/filesystems/romfs/SConscript b/components/dfs/filesystems/romfs/SConscript new file mode 100644 index 000000000..bfd633ce9 --- /dev/null +++ b/components/dfs/filesystems/romfs/SConscript @@ -0,0 +1,15 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') +CPPPATH = [cwd] + +if GetDepend('DFS_ROMFS_ROOT'): + # A new ROMFS root has been defined, we should remove the romfs.c + SrcRemove(src, ['romfs.c']) + +group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS','RT_USING_DFS_ROMFS'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/dfs/filesystems/uffs/SConscript b/components/dfs/filesystems/uffs/SConscript new file mode 100644 index 000000000..f822cf5d7 --- /dev/null +++ b/components/dfs/filesystems/uffs/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') +CPPPATH = [cwd, cwd + '/src/inc'] + +group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_UFFS'], CPPPATH = CPPPATH) + +Return('group') diff --git a/include/rtcomponents.h b/include/rtcomponents.h deleted file mode 100644 index 70accb99d..000000000 --- a/include/rtcomponents.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * File : rtcomponents.h - * header for RT-Thread components - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2012-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 - * 2012-09-20 Bernard Change the name to components.h - * And all components related header files. - * 2015-02-06 Bernard Rename the components.h to rtcom.h - */ - -#ifndef RTCOM_H__ -#define RTCOM_H__ - -#ifdef RT_USING_FINSH -#include -#include -#endif - -#ifdef RT_USING_LWIP -#include -#include -#endif - -#ifdef RT_USING_DFS -#include -#include -#ifdef RT_USING_DFS_ELMFAT -#include -#endif -#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS) -#include -#endif -#ifdef RT_USING_DFS_ROMFS -#include -#endif -#ifdef RT_USING_DFS_DEVFS -#include -#endif -#ifdef RT_USING_DFS_UFFS -#include -#endif -#ifdef RT_USING_DFS_JFFS2 -#include -#endif -#ifdef RT_USING_DFS_YAFFS2 -#include -#endif -#ifdef RT_USING_DFS_ROMFS -#include -#endif -#endif - -#ifdef RT_USING_PTHREADS -#include -#endif - -#ifdef RT_USING_MODULE -#include -#endif - -#endif - From 655054b1c52c103afb5c815eea408e112da26c7d Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 3 Apr 2015 14:27:56 +0000 Subject: [PATCH 10/11] [Kernel] Use main function in the Keil MDK --- src/init.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/init.c b/src/init.c index 3b95ea3a5..56b7e0bf8 100644 --- a/src/init.c +++ b/src/init.c @@ -122,9 +122,22 @@ void rt_components_init(void) } #ifdef RT_USING_USER_MAIN + void rt_application_init(void); void rt_hw_board_init(void); +#ifdef __CC_ARM +extern int $Super$$main(void); +/* re-define main function */ +int $Sub$$main(void) +{ + rt_hw_interrupt_disable(); + rtthread_startup(); + + return 0; +} +#endif + #ifndef RT_USING_HEAP /* if there is not enble heap, we should use static thread and stack. */ ALIGN(8) @@ -141,7 +154,11 @@ void main_thread_entry(void *parameter) rt_components_init(); /* invoke system main function */ +#ifdef __CC_ARM + $Sub$$main(); +#else main(); +#endif } void rt_application_init(void) From 1f95de43aa6f24d2684e40b1d9e1a60689f7651d Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 10 Apr 2015 06:35:59 +0000 Subject: [PATCH 11/11] [tools] Add package.json as building script --- tools/building.py | 5 ++++ tools/package.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tools/package.py diff --git a/tools/building.py b/tools/building.py index d95cf3672..c4702de82 100644 --- a/tools/building.py +++ b/tools/building.py @@ -595,6 +595,11 @@ def GlobSubDir(sub_dir, ext_name): dst.append(os.path.relpath(item, sub_dir)) return dst +def PackageSConscript(package): + from package import BuildPackage + + return BuildPackage(package) + def file_path_exist(path, *args): return os.path.exists(os.path.join(path, *args)) diff --git a/tools/package.py b/tools/package.py new file mode 100644 index 000000000..55b318b2a --- /dev/null +++ b/tools/package.py @@ -0,0 +1,74 @@ +# +# File : package.py +# This file is part of RT-Thread RTOS +# COPYRIGHT (C) 2006 - 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 +# 2015-04-10 Bernard First version +# + +# this script is used to build group with package.json instead of SConscript +import os +from building import * + +def ExtendPackageVar(package, var): + v = [] + if not package.has_key(var): + return v + + for item in package[var]: + v = v + [item] + + return v + +def BuildPackage(package): + import json + f = file(package) + package_json = f.read() + + # get package.json path + cwd = os.path.dirname(package) + + package = json.loads(package_json) + + # check package name + if not package.has_key('name'): + return [] + + # get depends + depend = ExtendPackageVar(package, 'depends') + + src = [] + if package.has_key('source_files'): + for src_file in package['source_files']: + src_file = os.path.join(cwd, src_file) + src += Glob(src_file) + + CPPPATH = [] + if package.has_key('CPPPATH'): + for path in package['CPPPATH']: + if path.startswith('/') and os.path.isdir(path): + CPPPATH = CPPPATH + [path] + else: + CPPPATH = CPPPATH + [os.path.join(cwd, path)] + + CPPDEFINES = ExtendPackageVar(package, 'CPPDEFINES') + + objs = DefineGroup(package['name'], src, depend = depend, CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) + + return objs