From 924264b277a2c01fed27d051d9e6a3913e0de975 Mon Sep 17 00:00:00 2001 From: bernard Date: Fri, 20 Mar 2015 12:44:02 +0800 Subject: [PATCH 1/5] 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 e449e0c2dc..7d24a33d6a 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 2/5] 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 125dcec198..f28e235b3f 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 3/5] 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 6fa540b9e7..b6455f73f4 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 fd287c2ad5..105aa0e4fc 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 958177c1f2..9a823e394c 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 41e90775d8..d32f116a9b 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 4/5] [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 0000000000..4113a8691b --- /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 edd207bcb7..5309c31d5a 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 0eda61b1ef..6d59365195 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 5/5] [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 73270969b8..0427a6d91b 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 52fddd9492..a4f342df33 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);