提交 0df78e45 编写于 作者: B Bernard Xiong

Merge pull request #40 from prife/sim-module

app module of simulator:update readme.txt, add rtthread.def for default ...
说明: 本BSP可以如下演示 说明: 本BSP可以如下演示
默认演示realtouch GUI效果,并提供了一个贪吃的demo用于演示
一 平台及组件支持
目前支持的功能有 目前rtconfig.py中支持的编译器有
1). LWIP(可以打开LWIP选项,不过尚存在bug,不建议使用) 1). msvc 用于windows平台
2). 文件系统支持,支持ELM FatFS,UFFS,JFFS2 此平台支持的组件
3). RTGUI支持 kernel
目前SVN中的RTGUI源码可以直接用于simulator。 finsh
如果读者想快速在simulator上体验RTGUI,那么不需要修改任何文件,首先在命令行中使用 LWIP
scons --target=vs -s DFS, ELM FatFS, UFFS, JFFS2, DFS_WIN32
生成工程后,打开project.vsproj编译,即可看到realtouch的ui出现,然后执行 RTGUI
在finsh中执行snake_main(),即可运行贪吃蛇demo APP MODULE
2). mingw 用于windows平台
再补充说明一点,RTGUI的最新源码目前是托管在git上。 kernel
github网页:https://github.com/RT-Thread/RTGUI finsh
如果要使用rtgui中的最新源码,共有两种方法。 DFS, ELM FatFS, UFFS, DFS_WIN32
RTGUI
APP MODULE
3). gcc 用于linux平台
kernel
finsh
DFS, ELM FatFS, UFFS
RTGUI
二 组件配置
1) RTGUI
当前代码中已经不含RTGUI源码,因此读者需要配置一下才能在simulator中使用RTGUI
RTGUI的最新源码目前是托管在github上:https://github.com/RT-Thread/RTGUI
共有两种方法。
方法1 添加环境变量 方法1 添加环境变量
向系统环境变量中加入RTT_RTGUI,其值为刚才github上下载的rtgui源码包的路径。 向系统加入RTT_RTGUI环境变量,其值为刚才github上下载的rtgui源码包的路径。
例如笔者的rtgui源码包解压至 F:\Project\git\rt-gui\下 例如笔者的rtgui源码包解压至 F:\Project\git\rt-gui\下, 则将此环境变量配置为 F:\Project\git\rt-gui\components\rtgui
则将此环境变量配置为 F:\Project\git\rt-gui\components\rtgui
方法2 不添加环境变量 方法2 不添加环境变量
打开SConstruct文件, 打开SConstruct文件,
.... ....
...@@ -37,106 +49,105 @@ ...@@ -37,106 +49,105 @@
1)#号表示注释,类似于c语言中的//, 1)#号表示注释,类似于c语言中的//,
2)其中15行的路径为你的RTGUI路径源码,注意不是压缩包路径,而是压缩包路径下的 components\rtgui目录的绝对路径。 2)其中15行的路径为你的RTGUI路径源码,注意不是压缩包路径,而是压缩包路径下的 components\rtgui目录的绝对路径。
1 编译: 三 编译
1.1 使用Visual Studio(2005以上版本) 1) 使用Visual Studio(2005以上版本)
在命令行中执行 scons --target=vs -s 可以生成vs2005的工程,名为project.vsproj 在当前目录中打开cmd,输入命令
`scons --target=vs -s`
编译后运行 可以生成project.vsproj,双击运行
1.2 使用scons编译,在当前目录中打开cmd,输入
scons -j4
编译完成后会在当前目录下生成 rtthrad-win32.exe,双击即可运行。
2. 测试文件系统
运行:
编译后运行,会弹出CMD命令行窗口,可以看到控制台的输出信息,如下所示
\ | /
- RT - Thread Operating System
/ | \ 1.1.0 build Oct 21 2012
2006 - 2012 Copyright by rt-thread team
init jffs2 lock mutex okay
hello, world
finsh>>fatfs initialzation failed!
uffs initialzation failed!
jffs2 initialzation failed!
thread 29e4 exit
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
thread 2898 exit
注意上面的信息显示,fatfs/uffs/jffs2均挂载失败,这是因为我们还没有为sd.bin创建fat分区,并且sd上也没有目录用于挂载jffs2和uffs。
并且此时当前bsp目录下,新增了三个文件用于模拟sd卡,nand flash与nor flash,它们是
sd.bin--模拟SD卡,挂载fat,大小为16M
nand.bin-模拟nand flash,挂载uffs,参数page=2048+64bytes,block=64pages,16M
nor.bin--模拟nor flash,挂载jffs2,型号为sst25vf,2M
按下回车,出现finsh,然后输入如下命令格式化sd.bin
2) 命令行编译
修改rtconfig.py, 配置合适的编译器(msvc/mingw/gcc),及其路径
在当前目录中打开cmd,输入命令
`scons -j4`
编译完成后会在当前目录下生成 rtthrad-win32.exe,双击即可运行。
四 程序测试
1) 测试文件系统
此时当前目录下,新增了三个文件
sd.bin--模拟SD卡,挂载fat,大小为16M
nand.bin-模拟nand flash,挂载uffs,参数page=2048+64bytes,block=64pages,16M
nor.bin--模拟nor flash,挂载jffs2,型号为sst25vf,2M
第一次启动时,会看到fatfs挂在失败。
按下回车,出现finsh,然后输入`mkfs("elm", "sd0")`格式化SD卡,如下所示
finsh>>mkfs("elm", "sd0") finsh>>mkfs("elm", "sd0")
0, 0x00000000 0, 0x00000000
finsh>> 然后重启程序,就可以看到fatfs挂载成功了
关闭程序重新运行,此时可以看到fatfs挂载成功,不过jffs2和uffs依然失败,如下所示。 2) 测试RTGUI
\ | / 启动后就会看到GUI窗口,分辨率800x480,此时在finsh中输入snake_main()并回车,即可运行贪吃蛇程序
- RT - Thread Operating System
/ | \ 1.1.0 build Oct 21 2012 3) 测试APP module
2006 - 2012 Copyright by rt-thread team rtconfig.h中需要打开RT_USING_MODULE
init jffs2 lock mutex okay
hello, world a. 生成rtthread.def文件
finsh>>fatfs initialized! 使用msv编译主程序时需要此文件,使用MingW编译主程序时不需要
uffs initialzation failed! msvc需要此文件才能生成正确导出符号的rtthread.dll和rtthread-win32.exe。
jffs2 initialzation failed! 此目录下默认自带了一个rtthread.def文件,当修改了rtconfig.h,禁用了某些组件时,则需要重新生成rtthread.def文件.
生成方法:
这是因为sd上还没有目录来用于挂载jffs2和uffs,在finsh中输入如下命令在sd上创建nand与nor文件夹,分别用于挂载uffs与jffs2文件系统。 需要借助MingW工具,修改rtconfig.py中CROSS_TOOL为'mingw',然后打开CMD执行`scons --def`就会自动更新rtthread.def。
finsh>>mkdir("/nand") b. 生成主程序
0, 0x00000000 主程序可以使用msvc和mingw生成
finsh>>mkdir("/nor") 如果rtconfig.h中的使能了RTGUI,则需要参考第二节第1小节配置RTGUI
0, 0x00000000 a.1 使用msvc
finsh>> 修改rtconfig.py中CROSS_TOOL为'msvc'
然后再次关闭程序后重新运行,此时可以看到jffs2与uffs挂载成功。 首先要保证当前目录下有合适的rtthread.def文件,如果没有对默认的rtconfig.h作修改,则使用默认的rtthread.def即可
CMD命令行执行`scons -j4`,即可生成rtthread.dll和 rtthread-win32.exe
最终输出如下所示: a.2 使用mingw
修改rtconfig.py中CROSS_TOOL为'mingw'
\ | / CMD命令行执行`scons -j4`,这就会生成 rtthread.dll和 rtthread-win32.exe
- RT - Thread Operating System
/ | \ 1.1.0 build Oct 21 2012 c. 生成app module
2006 - 2012 Copyright by rt-thread team 进入testdll目录,再次修改 testdll/SConstruct, 同样需要配置RTT_RTGUI路径,同 1中3)
init jffs2 lock mutex okay 在此目录下执行
hello, world `scons --app=basicapp`
finsh>>fatfs initialized! 就会在 basicapp/building目录下生成 basicapp.dll。
os : system memory alloc 320 bytes
flsh: ECC size 24 然后运行simulator目录下的 rtthread-win32.exe, 在finsh中运行
flsh: UFFS consume spare data size 34 `exec("/testdll/basicapp/building/basicapp.dll")`
os : system memory alloc 83520 bytes 如果觉得这个路径太长,就把 basicapp.dll复制到 simualtor目录下,执行
os : system memory alloc 52400 bytes `exec("/basicapp.dll")`
os : system memory alloc 2048 bytes
tree: DIR 0, FILE 0, DATA 0 如果想编译RTGUI应用,如testdll目录下的snake,则需要对RTGUI打一点补丁,共有两个方法
uffs initialized! 1. 注释掉 //#define RTGUI_USING_CAST_CHECK`
jffs2 initialized! 找到rtgui_config.h源码,注释掉如下语句
thread 2fb4 exit //#define RTGUI_USING_CAST_CHECK`
hello, world
hello, world 然后在testdll目录下打开CMD窗口,执行`scons --app=snake`,才可以正确编译,如果不注释掉上面的宏,则会出现链接错误。
hello, world
hello, world 2. 不注释掉#define RTGUI_USING_CAST_CHECK`
hello, world 那么需要如下两个补丁
hello, world 1) 修改testdll/SConstruct文件
hello, world diff --git a/bsp/simulator/testdll/SConstruct b/bsp/simulator/testdll/SConstruct
hello, world index 3324f88..005289c 100644
hello, world --- a/bsp/simulator/testdll/SConstruct
thread 312c exit +++ b/bsp/simulator/testdll/SConstruct
@@ -70,6 +70,7 @@ env.Append(CCFLAGS=rtconfig.CFLAGS)
Ok,到现在,一个完整的文件系统测试环境就搭建完毕了,enjoy~~ env.Append(LINKFLAGS=rtconfig.LFLAGS)
env.Append(CPPPATH=CPPPATH)
3 测试RTGUI env.Append(LIBS='rtthread', LIBPATH='../')
启动后就会看到GUI窗口,分辨率800×480串口,并出现图形界面。 +env.Append(CPPDEFINES=['RTT_IN_MODULE'])
此时在finsh中输入 snake_main()并回车,即可运行贪吃蛇程序。 env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
PrepareModuleBuilding(env, RTT_ROOT)
2) 修改RTGUI源码
diff --git a/components/rtgui/include/rtgui/rtgui_object.h b/components/rtgui/include/rtgui/rtgui_object.h
index 57fd47f..b32ee17 100644
--- a/components/rtgui/include/rtgui/rtgui_object.h
+++ b/components/rtgui/include/rtgui/rtgui_object.h
@@ -56,7 +56,12 @@ extern "C" {
typedef struct rtgui_type rtgui_type_t;
#define RTGUI_TYPE(type) (struct rtgui_type*)&(_rtgui_##type)
+#ifdef RTT_IN_MODULE
+#define DECLARE_CLASS_TYPE(type) _declspec(dllimport) const struct rtgui_type _rtgui_##type
+#else
#define DECLARE_CLASS_TYPE(type) extern const struct rtgui_type _rtgui_##type
+#endif
+
#define DEFINE_CLASS_TYPE(type, name, parent, constructor, destructor, size) \
const struct rtgui_type _rtgui_##type = { \
name, \
然后再编译snake,可以正确生成。测试方法同basicapp
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册