diff --git a/bsp/simulator/template.vcproj b/bsp/simulator/template_vs2005.vcproj similarity index 100% rename from bsp/simulator/template.vcproj rename to bsp/simulator/template_vs2005.vcproj diff --git a/bsp/simulator/template_vs2012.vcxproj b/bsp/simulator/template_vs2012.vcxproj new file mode 100644 index 0000000000..85e625e1ba --- /dev/null +++ b/bsp/simulator/template_vs2012.vcxproj @@ -0,0 +1,61 @@ + + + + + Debug + Win32 + + + + vs + {4A6BF1B1-C645-4BAD-A9B7-7B6E3DB67B2C} + vs2008 + Win32Proj + + + + Application + v110 + NotSet + + + + + + + + + + <_ProjectFileVersion>11.0.50727.1 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + + + + Disabled + .\;..\..\include;..\..\bsp\vs2008;..\..\components\finsh;..\..\components\dfs\include;..\..\components\dfs\filesystems\uffs\src\inc\;..\..\components\dfs\filesystems\uffs;..\..\components\drivers\include;..\..\components\dfs\filesystems\jffs2\src;..\..\components\dfs\filesystems\jffs2\kernel;..\..\components\dfs\filesystems\jffs2\include;..\..\components\dfs\filesystems\jffs2\;..\..\components\dfs\filesystems\jffs2\cyg\compress;..\..\components\init;.\drivers;..\..\components\net\lwip\src\include\;..\..\components\net\lwip\src;..\..\components\net\lwip\src\arch\include;..\..\components\net\lwip\src\include\ipv4;.\pcap\Include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;MSVC;_TIME_T_DEFINED;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + Level3 + EditAndContinue + + + winmm.lib;Packet.lib;wpcap.lib;%(AdditionalDependencies) + .\pcap\Lib;%(AdditionalLibraryDirectories) + true + Console + MachineX86 + + + + + + + + \ No newline at end of file diff --git a/components/dfs/filesystems/jffs2/dfs_jffs2.c b/components/dfs/filesystems/jffs2/dfs_jffs2.c index 3b96295c76..6516797544 100644 --- a/components/dfs/filesystems/jffs2/dfs_jffs2.c +++ b/components/dfs/filesystems/jffs2/dfs_jffs2.c @@ -178,6 +178,7 @@ static int dfs_jffs2_mount(struct dfs_filesystem* fs, result = jffs2_mount(NULL, mte); if (result != 0) { + device_partition[index].dev = NULL; return jffs2_result_to_dfs(result); } /* save this pointer */ diff --git a/components/dfs/filesystems/jffs2/src/fs-ecos.c b/components/dfs/filesystems/jffs2/src/fs-ecos.c index 5f3b5d607c..814d2e3010 100644 --- a/components/dfs/filesystems/jffs2/src/fs-ecos.c +++ b/components/dfs/filesystems/jffs2/src/fs-ecos.c @@ -747,7 +747,7 @@ int jffs2_open(cyg_mtab_entry * mte, cyg_dir dir, const char *name, } // Initialise the file object - file->f_flag |= mode & CYG_FILE_MODE_MASK; + file->f_flag = mode & CYG_FILE_MODE_MASK; file->f_type = CYG_FILE_TYPE_FILE; file->f_ops = &jffs2_fileops; file->f_offset = (mode & O_APPEND) ? node->i_size : 0; @@ -1065,6 +1065,7 @@ static int jffs2_opendir(cyg_mtab_entry * mte, cyg_dir dir, const char *name, // Initialize the file object, setting the f_ops field to a // special set of file ops. + file->f_flag = 0; file->f_type = CYG_FILE_TYPE_FILE; file->f_ops = &jffs2_dirops; file->f_offset = 0; diff --git a/components/finsh/msh_cmd.c b/components/finsh/msh_cmd.c index fac90479c8..cffb374c2e 100644 --- a/components/finsh/msh_cmd.c +++ b/components/finsh/msh_cmd.c @@ -136,6 +136,7 @@ int cmd_rm(int argc, char** argv) } FINSH_FUNCTION_EXPORT_ALIAS(cmd_rm, __cmd_rm, "Remove (unlink) the FILE(s)."); +#ifdef DFS_USING_WORKDIR int cmd_cd(int argc, char** argv) { if (argc == 1) @@ -157,6 +158,7 @@ int cmd_pwd(int argc, char** argv) return 0; } FINSH_FUNCTION_EXPORT_ALIAS(cmd_pwd, __cmd_pwd, Print the name of the current working directory.); +#endif int cmd_mkdir(int argc, char** argv) { diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 19dd93691e..8ff0e89e44 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -131,6 +131,7 @@ void finsh_set_device(const char* device_name) { /* close old finsh device */ rt_device_close(shell->device); + rt_device_set_rx_indicate(dev, RT_NULL); } shell->device = dev; diff --git a/components/utilities/logtrace/log_file.c b/components/utilities/logtrace/log_file.c index 72e4724b63..2f4a28b63c 100644 --- a/components/utilities/logtrace/log_file.c +++ b/components/utilities/logtrace/log_file.c @@ -121,6 +121,9 @@ void log_trace_set_file(const char *filename) log_trace_file_init(filename); log_trace_set_device("logfile"); } +#ifdef RT_USING_FINSH +#include FINSH_FUNCTION_EXPORT_ALIAS(log_trace_set_file, log_file, set output filename of log trace); +#endif #endif /* RT_USING_DFS */ diff --git a/components/utilities/logtrace/log_trace.c b/components/utilities/logtrace/log_trace.c index 79d5a21884..cc55b1dd44 100644 --- a/components/utilities/logtrace/log_trace.c +++ b/components/utilities/logtrace/log_trace.c @@ -41,7 +41,7 @@ static struct rt_device _log_device; static rt_device_t _traceout_device = RT_NULL; /* define a default lg session. The name is empty. */ -static struct log_trace_session _def_session = {{0}, LOG_TRACE_LEVEL_INFO}; +static struct log_trace_session _def_session = {{"\0"}, LOG_TRACE_LEVEL_INFO}; static struct log_trace_session *_the_sessions[LOG_TRACE_MAX_SESSION] = {&_def_session}; /* there is a default session at least */ static rt_uint16_t _the_sess_nr = 1; @@ -272,7 +272,7 @@ static void _lg_fmtout( _trace_buf[0] = ']'; ptr = &_trace_buf[1]; - length = vsnprintf(ptr, LOG_TRACE_BUFSZ, fmt, argptr); + length = rt_vsnprintf(ptr, LOG_TRACE_BUFSZ, fmt, argptr); if (length >= LOG_TRACE_BUFSZ) length = LOG_TRACE_BUFSZ - 1; diff --git a/components/utilities/logtrace/log_trace.h b/components/utilities/logtrace/log_trace.h index d5a028f553..77e1f08b6c 100644 --- a/components/utilities/logtrace/log_trace.h +++ b/components/utilities/logtrace/log_trace.h @@ -31,9 +31,10 @@ #define LOG_TRACE_LEVEL_MASK 0x0f #define LOG_TRACE_LEVEL_NOTRACE 0x00 #define LOG_TRACE_LEVEL_ERROR 0x01 -#define LOG_TRACE_LEVEL_WARNING 0x02 -#define LOG_TRACE_LEVEL_INFO 0x03 -#define LOG_TRACE_LEVEL_DEBUG 0x04 +#define LOG_TRACE_LEVEL_WARNING 0x03 +#define LOG_TRACE_LEVEL_INFO 0x05 +#define LOG_TRACE_LEVEL_VERBOSE 0x07 +#define LOG_TRACE_LEVEL_DEBUG 0x09 #define LOG_TRACE_LEVEL_ALL 0x0f #ifndef LOG_TRACE_LEVEL_DEFAULT @@ -41,9 +42,10 @@ #endif #define LOG_TRACE_ERROR "<1>" -#define LOG_TRACE_WARNING "<2>" -#define LOG_TRACE_INFO "<3>" -#define LOG_TRACE_DEBUG "<4>" +#define LOG_TRACE_WARNING "<3>" +#define LOG_TRACE_INFO "<5>" +#define LOG_TRACE_VERBOSE "<7>" +#define LOG_TRACE_DEBUG "<9>" #define LOG_TRACE_OPT_NOTS 0x10 /* no timestamp */ #define LOG_TRACE_OPT_LN 0x20 /* terminate the current line */ @@ -140,12 +142,12 @@ rt_err_t log_trace_set_device(const char *device_name); void log_trace_flush(void); +#ifdef RT_USING_DFS /** set the backend to file */ void log_trace_set_file(const char *filename); -/* log trace for NAND Flash */ -void log_trace_nand_init(const char *nand_device); void log_trace_file_init(const char *filename); +#endif /* RT_USING_DFS */ #endif diff --git a/include/rtthread.h b/include/rtthread.h index 28c0192291..b68a301a5c 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -469,6 +469,7 @@ int rt_system_module_init(void); void rt_kprintf(const char *fmt, ...); #endif rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr); +rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args); rt_int32_t rt_sprintf(char *buf ,const char *format, ...); rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...); diff --git a/libcpu/arm/am335x/SConscript b/libcpu/arm/am335x/SConscript deleted file mode 100644 index 2ad51b573e..0000000000 --- a/libcpu/arm/am335x/SConscript +++ /dev/null @@ -1,17 +0,0 @@ -Import('rtconfig') -from building import * - -cwd = GetCurrentDir() -src = Glob('*.c') -CPPPATH = [cwd] - -if rtconfig.PLATFORM == 'iar': - src += Glob('*_iar.S') -elif rtconfig.PLATFORM == 'gcc': - src += Glob('*_gcc.S') -elif rtconfig.PLATFORM == 'armcc': - src += Glob('*_rvds.S') - -group = DefineGroup('AM1808', src, depend = [''], CPPPATH = CPPPATH) - -Return('group') diff --git a/src/kservice.c b/src/kservice.c index ff5ff9de2a..c2fa43ba73 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -718,10 +718,10 @@ static char *print_number(char *buf, return buf; } -static rt_int32_t vsnprintf(char *buf, - rt_size_t size, - const char *fmt, - va_list args) +rt_int32_t rt_vsnprintf(char *buf, + rt_size_t size, + const char *fmt, + va_list args) { #ifdef RT_PRINTF_LONGLONG unsigned long long num; @@ -976,6 +976,7 @@ static rt_int32_t vsnprintf(char *buf, */ return str - buf; } +RTM_EXPORT(rt_vsnprintf); /** * This function will fill a formatted string to buffer @@ -990,7 +991,7 @@ rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) va_list args; va_start(args, fmt); - n = vsnprintf(buf, size, fmt, args); + n = rt_vsnprintf(buf, size, fmt, args); va_end(args); return n; @@ -1006,7 +1007,7 @@ RTM_EXPORT(rt_snprintf); */ rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr) { - return vsnprintf(buf, (rt_size_t) -1, format, arg_ptr); + return rt_vsnprintf(buf, (rt_size_t) -1, format, arg_ptr); } RTM_EXPORT(rt_vsprintf); @@ -1114,7 +1115,7 @@ void rt_kprintf(const char *fmt, ...) * large excluding the terminating null byte. If the output string * would be larger than the rt_log_buf, we have to adjust the output * length. */ - length = vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args); + length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args); if (length > RT_CONSOLEBUF_SIZE - 1) length = RT_CONSOLEBUF_SIZE - 1; #ifdef RT_USING_DEVICE diff --git a/tools/building.py b/tools/building.py index 65bd14d882..acc3a8a213 100644 --- a/tools/building.py +++ b/tools/building.py @@ -139,6 +139,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ 'mdk4':('keil', 'armcc'), 'iar':('iar', 'iar'), 'vs':('msvc', 'cl'), + 'vs2012':('msvc', 'cl'), 'cb':('keil', 'armcc')} tgt_name = GetOption('target') if tgt_name: @@ -347,12 +348,14 @@ def DoBuilding(target, objects): EndBuilding(target, program) + def EndBuilding(target, program = None): import rtconfig from keil import MDKProject from keil import MDK4Project from iar import IARProject from vs import VSProject + from vs2012 import VS2012Project from codeblocks import CBProject Env.AddPostAction(target, rtconfig.POST_ACTION) @@ -377,6 +380,9 @@ def EndBuilding(target, program = None): if GetOption('target') == 'vs': VSProject('project.vcproj', Projects, program) + if GetOption('target') == 'vs2012': + VS2012Project('project.vcxproj', Projects, program) + if GetOption('target') == 'cb': CBProject('project.cbp', Projects, program) diff --git a/tools/vs.py b/tools/vs.py index 1cb0f1a809..1dce0ddaa7 100644 --- a/tools/vs.py +++ b/tools/vs.py @@ -40,7 +40,7 @@ def VS_AddHeadFilesGroup(program, elem, project_path): def VSProject(target, script, program): project_path = os.path.dirname(os.path.abspath(target)) - tree = etree.parse('template.vcproj') + tree = etree.parse('template_vs2005.vcproj') root = tree.getroot() out = file(target, 'wb') diff --git a/tools/vs2012.py b/tools/vs2012.py new file mode 100644 index 0000000000..3e751e940e --- /dev/null +++ b/tools/vs2012.py @@ -0,0 +1,190 @@ +import os +import sys +import string +import building +import uuid + +import xml.etree.ElementTree as etree +from xml.etree.ElementTree import SubElement +from utils import _make_path_relative +from utils import xml_indent +fs_encoding = sys.getfilesystemencoding() + +#reference +# http://woodpecker.org.cn/diveintopython3/xml.html +# https://pycoders-weekly-chinese.readthedocs.org/en/latest/issue6/processing-xml-in-python-with-element-tree.html +# http://www.cnblogs.com/ifantastic/archive/2013/04/12/3017110.html + +filter_project = etree.Element('Project', attrib={'ToolsVersion':'4.0'}) +def get_uuid(): + id = uuid.uuid1() # UUID('3e5526c0-2841-11e3-a376-20cf3048bcb3') + idstr = id.get_urn()[9:] #'urn:uuid:3e5526c0-2841-11e3-a376-20cf3048bcb3'[9:] + return '{'+idstr+'}' + +def VS2012_AddGroup(parent, group_name, files, project_path): + for f in files: + fn = f.rfile() + name = fn.name + path = os.path.dirname(fn.abspath) + + path = _make_path_relative(project_path, path) + path = os.path.join(path, name) + + ClCompile = SubElement(parent, 'ClCompile') + ClCompile.set('Include', path.decode(fs_encoding)) + + Filter = SubElement(ClCompile, 'Filter') + Filter.text='Source Files\\'+group_name + +def VS2012_CreateFilter(script, project_path): + c_ItemGroup = SubElement(filter_project, 'ItemGroup') + filter_ItemGroup = SubElement(filter_project, 'ItemGroup') + + Filter = SubElement(filter_ItemGroup, 'Filter') + Filter.set('Include', 'Source Files') + UniqueIdentifier = SubElement(Filter, 'UniqueIdentifier') + UniqueIdentifier.text = get_uuid() + Extensions = SubElement(Filter, 'Extensions') + Extensions.text = 'cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx' + + Filter = SubElement(filter_ItemGroup, 'Filter') + Filter.set('Include', 'Header Files') + UniqueIdentifier = SubElement(Filter, 'UniqueIdentifier') + UniqueIdentifier.text = get_uuid() + Extensions = SubElement(Filter, 'Extensions') + Extensions.text = 'h;hpp;hxx;hm;inl;inc;xsd' + for group in script: + VS2012_AddGroup(c_ItemGroup, group['name'], group['src'], project_path) + Filter = SubElement(filter_ItemGroup, 'Filter') + Filter.set('Include', 'Source Files\\'+group['name']) + UniqueIdentifier = SubElement(Filter, 'UniqueIdentifier') + UniqueIdentifier.text = get_uuid() + +#program: object from scons +# parent: xml node +# file_type: C or H +# files: c/h list +# project_path +def VS_add_ItemGroup(parent, file_type, files, project_path): + file_dict = {'C':"ClCompile", 'H':'ClInclude'} + item_tag = file_dict[file_type] + + ItemGroup = SubElement(parent, 'ItemGroup') + for f in files: + fn = f.rfile() + name = fn.name + path = os.path.dirname(fn.abspath) + + path = _make_path_relative(project_path, path) + path = os.path.join(path, name) + + File = SubElement(ItemGroup, item_tag) + File.set('Include', path.decode(fs_encoding)) + +def VS_add_HeadFiles(program, elem, project_path): + building.source_ext = [] + building.source_ext = ["h"] + for item in program: + building.walk_children(item) + building.source_list.sort() + # print building.source_list + ItemGroup = SubElement(elem, 'ItemGroup') + + filter_h_ItemGroup = SubElement(filter_project, 'ItemGroup') + for f in building.source_list: + path = _make_path_relative(project_path, f) + File = SubElement(ItemGroup, 'ClInclude') + File.set('Include', path.decode(fs_encoding)) + + # add project.vcxproj.filter + ClInclude = SubElement(filter_h_ItemGroup, 'ClInclude') + ClInclude.set('Include', path.decode(fs_encoding)) + Filter = SubElement(ClInclude, 'Filter') + Filter.text='Header Files' + +def VS2012Project(target, script, program): + project_path = os.path.dirname(os.path.abspath(target)) + + tree = etree.parse('template_vs2012.vcxproj') + root = tree.getroot() + elem = root + + out = file(target, 'wb') + out.write('\r\n') + + ProjectFiles = [] + + # add "*.c or *.h" files + + VS2012_CreateFilter(script, project_path) + # add "*.c" files + for group in script: + VS_add_ItemGroup(elem, 'C', group['src'], project_path) + + # add "*.h" files + VS_add_HeadFiles(program, elem, project_path) + + # write head include path + if building.Env.has_key('CPPPATH'): + cpp_path = building.Env['CPPPATH'] + paths = set() + for path in cpp_path: + inc = _make_path_relative(project_path, os.path.normpath(path)) + paths.add(inc) #.replace('\\', '/') + + paths = [i for i in paths] + paths.sort() + cpp_path = ';'.join(paths) + ';%(AdditionalIncludeDirectories)' + + # write include path + for elem in tree.iter(tag='AdditionalIncludeDirectories'): + elem.text = cpp_path + break + + # write cppdefinitons flags + if building.Env.has_key('CPPDEFINES'): + for elem in tree.iter(tag='PreprocessorDefinitions'): + definitions = ';'.join(building.Env['CPPDEFINES']) + ';%(PreprocessorDefinitions)' + elem.text = definitions + break + # write link flags + + # write lib dependence (Link) + if building.Env.has_key('LIBS'): + for elem in tree.iter(tag='AdditionalDependencies'): + libs_with_extention = [i+'.lib' for i in building.Env['LIBS']] + libs = ';'.join(libs_with_extention) + ';%(AdditionalDependencies)' + elem.text = libs + break + + # write lib include path + if building.Env.has_key('LIBPATH'): + lib_path = building.Env['LIBPATH'] + paths = set() + for path in lib_path: + inc = _make_path_relative(project_path, os.path.normpath(path)) + paths.add(inc) + + paths = [i for i in paths] + paths.sort() + lib_paths = ';'.join(paths) + ';%(AdditionalLibraryDirectories)' + for elem in tree.iter(tag='AdditionalLibraryDirectories'): + elem.text = lib_paths + break + + xml_indent(root) + vcxproj_string = etree.tostring(root, encoding='utf-8') + root_node=r'' + out.write(r'') + out.write(vcxproj_string[len(root_node):]) + out.close() + + xml_indent(filter_project) + filter_string = etree.tostring(filter_project, encoding='utf-8') + out = file('project.vcxproj.filters', 'wb') + out.write('\r\n') + root_node=r'' + out.write(r'') + out.write(filter_string[len(root_node):]) + out.close() +