From 3d0c0af3718a89a5d614b79ea9910bdc5409415f Mon Sep 17 00:00:00 2001 From: Grissiom Date: Sat, 31 Aug 2013 16:30:32 +0800 Subject: simulator: fix SDL initialization under Linux rt_hw_sdl_start should wait untill the rtgui_graphic_set_device is called int the sdl_loop. Use pthread_cond_wait to achieve this in Linux. --- bsp/simulator/drivers/sdl_fb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'bsp') diff --git a/bsp/simulator/drivers/sdl_fb.c b/bsp/simulator/drivers/sdl_fb.c index d7ebbc8245..78bca6f07f 100755 --- a/bsp/simulator/drivers/sdl_fb.c +++ b/bsp/simulator/drivers/sdl_fb.c @@ -152,8 +152,12 @@ static void sdlfb_hw_init(void) #ifdef _WIN32 static HANDLE sdl_ok_event = NULL; + static DWORD WINAPI sdl_loop(LPVOID lpParam) #else +static pthread_mutex_t sdl_ok_mutex; +static pthread_cond_t sdl_ok_event; + static void *sdl_loop(void *lpParam) #endif { @@ -167,14 +171,19 @@ static void *sdl_loop(void *lpParam) /* set the getchar without buffer */ sigfillset(&sigmask); pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask); + pthread_mutex_lock(&sdl_ok_mutex); #endif sdlfb_hw_init(); device = rt_device_find("sdl"); + RT_ASSERT(device); rtgui_graphic_set_device(device); #ifdef _WIN32 SetEvent(sdl_ok_event); +#else + pthread_cond_signal(&sdl_ok_event); + pthread_mutex_unlock(&sdl_ok_mutex); #endif /* handle SDL event */ while (!quit) @@ -338,11 +347,20 @@ void rt_hw_sdl_start(void) /* Linux */ pthread_t pid; int res; + + pthread_mutex_init(&sdl_ok_mutex, NULL); + pthread_cond_init(&sdl_ok_event, NULL); + res = pthread_create(&pid, NULL, &sdl_loop, NULL); if (res) { printf("pthread create sdl thread faild, <%d>\n", res); exit(EXIT_FAILURE); } + pthread_mutex_lock(&sdl_ok_mutex); + pthread_cond_wait(&sdl_ok_event, &sdl_ok_mutex); + + pthread_mutex_destroy(&sdl_ok_mutex); + pthread_cond_destroy(&sdl_ok_event); #endif } -- cgit v1.3.1 From 6563ae6cab1615df3e1abbccf8df1498934983f9 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Sat, 31 Aug 2013 16:46:36 +0800 Subject: simulator: init SDL after rt_components_init SDL may use DFS to open files. It should be run after rt_components_init. --- bsp/simulator/applications/application.c | 6 ++++++ bsp/simulator/applications/platform.c | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'bsp') diff --git a/bsp/simulator/applications/application.c b/bsp/simulator/applications/application.c index 4abecb872e..ea07f01c5f 100755 --- a/bsp/simulator/applications/application.c +++ b/bsp/simulator/applications/application.c @@ -30,6 +30,12 @@ void rt_init_thread_entry(void *parameter) /* initialization RT-Thread Components */ rt_components_init(); +#ifdef RT_USING_RTGUI + /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be + * called after rt_components_init. */ + rt_hw_sdl_start(); +#endif /* RT_USING_RTGUI */ + #if defined(RT_USING_COMPONENTS_INIT) && defined(__GNUC__) && defined(RT_USING_FINSH) finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif diff --git a/bsp/simulator/applications/platform.c b/bsp/simulator/applications/platform.c index 3c7ffdb541..fbc1003d2a 100644 --- a/bsp/simulator/applications/platform.c +++ b/bsp/simulator/applications/platform.c @@ -17,11 +17,6 @@ void rt_platform_init(void) #endif /* RT_USING_DFS */ -#ifdef RT_USING_RTGUI - /* start sdl thread to simulate an LCD */ - rt_hw_sdl_start(); -#endif /* RT_USING_RTGUI */ - #ifdef _WIN32 rt_thread_idle_sethook(rt_hw_win32_low_cpu); #endif -- cgit v1.3.1 From d70761222c4924aac9105ddbbe62089c1118c712 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Tue, 3 Sep 2013 20:09:45 +0800 Subject: stm32f10x: fix the rtgui initialization The rtgui_system_server_init prototype is wrong. And if we use RT_USING_COMPONENTS_INIT, there is no need to call rtgui_system_server_init again. --- bsp/stm32f10x/applications/application.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bsp') diff --git a/bsp/stm32f10x/applications/application.c b/bsp/stm32f10x/applications/application.c index 7031711460..d57bb4e4c0 100644 --- a/bsp/stm32f10x/applications/application.c +++ b/bsp/stm32f10x/applications/application.c @@ -111,7 +111,6 @@ void rt_init_thread_entry(void* parameter) #ifdef RT_USING_RTGUI { - extern void rtgui_system_server_init(void); extern void rt_hw_lcd_init(); extern void rtgui_touch_hw_init(void); @@ -132,8 +131,10 @@ void rt_init_thread_entry(void* parameter) /* set lcd device as rtgui graphic driver */ rtgui_graphic_set_device(lcd); +#ifndef RT_USING_COMPONENTS_INIT /* init rtgui system server */ rtgui_system_server_init(); +#endif calibration_set_restore(cali_setup); calibration_set_after(cali_store); -- cgit v1.3.1 From c6e81b58d9da3866287b02f48e231db7d272acd5 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Fri, 6 Sep 2013 21:32:27 +0800 Subject: simulator: move SDL setting staff into drivers/SConstruct This could not only make a cleaner SConstruct, but could also benefit RTGUI building. --- bsp/simulator/SConstruct | 7 ------- bsp/simulator/drivers/SConscript | 14 +++++++++++--- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'bsp') diff --git a/bsp/simulator/SConstruct b/bsp/simulator/SConstruct index af6534906b..b2e958e65b 100755 --- a/bsp/simulator/SConstruct +++ b/bsp/simulator/SConstruct @@ -84,13 +84,6 @@ else: objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False, remove_components=['rtgui']) if GetDepend('RT_USING_RTGUI'): - sdl_lib = ['SDL', 'SDLmain'] - sdl_lib_path = [os.path.abspath('SDL/lib/x86')] - sdl_include_path = [os.path.abspath('SDL/include')] - env.Append(LIBS=sdl_lib) - env.Append(LIBPATH=sdl_lib_path) - env.Append(CPPPATH=sdl_include_path) - if RTT_RTGUI: objs += SConscript(os.path.join(RTT_RTGUI, 'SConscript'), variant_dir='build/components/rtgui', diff --git a/bsp/simulator/drivers/SConscript b/bsp/simulator/drivers/SConscript index d939535da8..eb491b810e 100644 --- a/bsp/simulator/drivers/SConscript +++ b/bsp/simulator/drivers/SConscript @@ -3,10 +3,19 @@ from building import * cwd = GetCurrentDir() src = Glob('*.c') +LIBS = [] +LIBPATH = [] +CPPPATH = [cwd] # remove no need file. if GetDepend('RT_USING_RTGUI') == False: SrcRemove(src, 'sdl_fb.c') +else: + LIBS.append('SDL') + if sys.platform == 'win32': + LIBPATH.append(os.path.abspath(os.path.join(cwd, '../SDL/lib/x86'))) + CPPPATH.append(os.path.abspath(os.path.join(cwd, '../SDL/include'))) + if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_DFS_ELMFAT') == False: SrcRemove(src, 'sd_sim.c') if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_MTD_NAND') == False: @@ -20,8 +29,7 @@ if GetDepend('RT_USING_MODULE') == False: if sys.platform[0:5]=="linux": #check whether under linux SrcRemove(src, ['module_win32.c', 'dfs_win32.c']) -CPPPATH = [cwd] - -group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) +group = DefineGroup('Drivers', src, depend = [''], + CPPPATH = CPPPATH, LIBS=LIBS, LIBPATH=LIBPATH) Return('group') -- cgit v1.3.1 From 18692c29b8d8a24dcd6710c4bea4339789c21c17 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Fri, 6 Sep 2013 21:54:27 +0800 Subject: simulator: get CROSS_TOOL and EXEC_PATH from env Simulator get it's way to Travis CI ready. --- bsp/simulator/rtconfig.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bsp') diff --git a/bsp/simulator/rtconfig.py b/bsp/simulator/rtconfig.py index 7a42bddbcf..9328a087f8 100755 --- a/bsp/simulator/rtconfig.py +++ b/bsp/simulator/rtconfig.py @@ -1,3 +1,5 @@ +import os + # toolchains options ARCH='sim' #CROSS_TOOL='msvc' or 'gcc' or 'mingw' @@ -5,6 +7,9 @@ ARCH='sim' # 'gcc' is for linux CROSS_TOOL='msvc' +if os.getenv('RTT_CC'): + CROSS_TOOL = os.getenv('RTT_CC') + # cross_tool provides the cross compiler # EXEC_PATH is the compiler execute path if CROSS_TOOL == 'gcc': @@ -26,6 +31,9 @@ else : print "bad CROSS TOOL!" exit(1) +if os.getenv('RTT_EXEC_PATH'): + EXEC_PATH = os.getenv('RTT_EXEC_PATH') + BUILD = 'debug' #BUILD = '' -- cgit v1.3.1 From 35cac170fa0cf6829afda14ecc124b20bce2b061 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Sat, 7 Sep 2013 15:01:28 +0800 Subject: simulator: add clang-analyze tool support When CROSS_TOOL or 'RTT_CC' env is setted to 'clang-analyze', it will use Clang to check the codes. --- bsp/simulator/SConstruct | 4 ++++ bsp/simulator/rtconfig.py | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'bsp') diff --git a/bsp/simulator/SConstruct b/bsp/simulator/SConstruct index b2e958e65b..4db7328f2a 100755 --- a/bsp/simulator/SConstruct +++ b/bsp/simulator/SConstruct @@ -73,6 +73,10 @@ elif rtconfig.PLATFORM == 'mingw': LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env['LIBS']=libs env.PrependENVPath('PATH', rtconfig.EXEC_PATH) +elif rtconfig.CROSS_TOOL == 'clang-analyze': + TARGET = 'rtthread' + env = Environment(toolpath=[os.path.join(RTT_ROOT, 'tools', 'tools')], + tools = [rtconfig.CROSS_TOOL]) else: TARGET = 'rtthread' env['CC']=rtconfig.CC diff --git a/bsp/simulator/rtconfig.py b/bsp/simulator/rtconfig.py index 9328a087f8..d3ed2599d5 100755 --- a/bsp/simulator/rtconfig.py +++ b/bsp/simulator/rtconfig.py @@ -12,10 +12,10 @@ if os.getenv('RTT_CC'): # cross_tool provides the cross compiler # EXEC_PATH is the compiler execute path -if CROSS_TOOL == 'gcc': +if CROSS_TOOL == 'gcc' or CROSS_TOOL == 'clang-analyze': CPU = 'posix' PLATFORM = 'gcc' - EXEC_PATH = '/usr/bin/gcc' + EXEC_PATH = '' elif CROSS_TOOL == 'mingw': CPU = 'win32' @@ -26,8 +26,7 @@ elif CROSS_TOOL == 'msvc': CPU = 'win32' PLATFORM = 'cl' EXEC_PATH = '' - -else : +else: print "bad CROSS TOOL!" exit(1) -- cgit v1.3.1