今天在尋找Qt 時
找到以下網頁
http://doc.qt.nokia.com/latest/templates.html
解釋了為什麼Qt 要用 moc 的方式而不改用 template 方式來實現
signal/slot
太多人在論壇上 argue moc 的方式不標準 bla bla bla
其實那是種無聊的完美主義 或標準主義
任何東西好用的就是好用 不管標準與否
任何東西越多人使用 它就是標準 不僅如此 它還超越了標準
相反的 任何標準 如果不好用 或少人使用
那麼標準也只是 useless standard
比如說 JPEG2000
所以標準與否 並不是那麼重要
工程師應該要以實用主義為優先
所謂的不管白貓黑貓 會抓老鼠的就是好貓
不要被標準 或完美所沖昏了頭
世上並沒有完美的事物 很多事都是妥協的結果
換個角度來看 真實存在的東西 就是完美的
不存在的東西 只是虛幻
想一想 一開始標準的設定 也是為了讓大家更方便 能夠互通
事情更好做 而非硬性規定完全得符合 standard.
Standard 只是個範本,而實際上的運用,必須因時地而修改或變通。
2011年7月21日 星期四
FTP on WINCE, WININET
用VS2008 寫了一個ftp 的程式,但是很奇怪的 無法正常run
會顯示 cannot execute XXX.EXE
而且只要有 call InternetOpen() 就會顯示 cannot execute \USB Disk\Ftpce.exe
如果隨便亂打 abcd.exe 只會顯示 cannot execute abcd.exe
甚至連第一行的 printf 都不會執行
但是把InterOpen() 等函式拿掉
就可正常執行
try 很多方法,最後發現原因在於System Image 中沒有 include wininet 的元件
InternetOpen(), InternetConnect(), FtpOpenFile() 都要include wininet.lib
而 WinInet 在 Browser componet (IE6) 下面,叫做 Windows Internet Services
加入之後就ok了
總之 要使用 WinInet functions,要先加入 Windows Internet Services.
然後
#include
link wininet.lib ( at \WINCE500\PUBLIC\IE\OAK\LIB\....)
可以正常Link & Run 之後
就開始寫 ftp program
前面很順利,但是用到 FtpPutFile 時
卻回傳 550 Forbidden filename
卡住了好久後發現 forbidden filename 是因為
1. 在那個目錄裏沒有權限寫入
2. 路徑不對 在Linux 下的路徑要用 / 而不是 \
所以要指定 /Public/test.wav 而不是 \\Public\\test.wav
或 /test.wav
然後使用 FtpPutFile 之後 發現速度甚至比SMB還要慢
應該是內部處理很差的關係(或者是buffer 太小)
改用 FtpOpenFile + InternetWriteFile, buffer size 512K之後就正確了
比SMB還要快一些 ~ 10%-15%
會顯示 cannot execute XXX.EXE
而且只要有 call InternetOpen() 就會顯示 cannot execute \USB Disk\Ftpce.exe
如果隨便亂打 abcd.exe 只會顯示 cannot execute abcd.exe
甚至連第一行的 printf 都不會執行
但是把InterOpen() 等函式拿掉
就可正常執行
try 很多方法,最後發現原因在於System Image 中沒有 include wininet 的元件
InternetOpen(), InternetConnect(), FtpOpenFile() 都要include wininet.lib
而 WinInet 在 Browser componet (IE6) 下面,叫做 Windows Internet Services
加入之後就ok了
總之 要使用 WinInet functions,要先加入 Windows Internet Services.
然後
#include
link wininet.lib ( at \WINCE500\PUBLIC\IE\OAK\LIB\....)
可以正常Link & Run 之後
就開始寫 ftp program
前面很順利,但是用到 FtpPutFile 時
卻回傳 550 Forbidden filename
卡住了好久後發現 forbidden filename 是因為
1. 在那個目錄裏沒有權限寫入
2. 路徑不對 在Linux 下的路徑要用 / 而不是 \
所以要指定 /Public/test.wav 而不是 \\Public\\test.wav
或 /test.wav
然後使用 FtpPutFile 之後 發現速度甚至比SMB還要慢
應該是內部處理很差的關係(或者是buffer 太小)
改用 FtpOpenFile + InternetWriteFile, buffer size 512K之後就正確了
比SMB還要快一些 ~ 10%-15%
2011年7月6日 星期三
Network speed -- slow SMB
因為客戶抱怨網路 (Save to Server) 的速度
就開始了艱難的旅程
如何增進網路的速度呢? 大哉問
這是個困難的問題
因為網路速度牽扯到很多層面
光 OSI model 就有七層 Layer
AP 啦,Protocol 啦, 網路卡, 網路線, Server,甚至OS 在在都會影響傳輸的速度
一開始從 Network Driver 看起..., bla bla bla 頭暈了,
要先熟悉 NDIS架構,很熟中斷流程,看ISRHandler
看了後 也不知要從何改起
搞了很久,做了一些測試,最後靈感來了,覺得SMB要負起很大的責任
首先
上傳約100MB大小的檔案至 Linux File Server, 大約為 1.8MB/s
共54秒
再來直接連PC 傳至Windows XP, 變得更慢,耗時62~64秒
Why?
Google 了一下 SMB,它是個 Chatty (很囉嗦的) protocol
http://en.wikipedia.org/wiki/Server_Message_Block#cite_note-6
而且Max Block Size 只有64KB
也就是說 最少每64KB就要communicate 一次
這個overhead 不可謂不高,尤其是在High Latency Network中
所以MS 在Vista後推出來 SMB 2.0
可惜的是 WINCE 5大概無緣享受
所以要加快速度 就是要 reduce overhead, increase block size
看看上面,為什麼直接連線至PC 不經過 router 反而比較慢呢
使用 MS Network Monitor 後發現
那是因為 WinXP default MaxBufferSize 為4356
比Linux Server 的16644 還低
所以要加速 SMB(CIFS) Performance
要調大 block size 到極限64KB
http://blogs.msdn.com/b/openspecification/archive/2009/04/10/smb-maximum-transmit-buffer-size-and-performance-tuning.aspx
http://support.microsoft.com/kb/279282/en-us
在 SMB Server (也就是Windows PC) 端
The MaxBufferSize can be configured through the following registry setting:
Network Monitor 很好用
怎麼看 current smb buffer size 呢 -- R Negotiate
SMB servers return a maximum SERVER buffer size (MaxTransmotBufferSize) in the SMB negotiation response (SMB_COM_NEGOTIATE server response).
而 client 則是在 SetupANDX
The SMB client sends a maximum CLIENT buffer size to the server in SMB Session Setup request (SMB_COM_SESSION_SETUPANDX request) telling the sever what the maximum buffer size the client can support.
SPNEGO -- Linux Server
SMB Signing
Network Monitor
http://sls.weco.net/node/10698
Network Capture 的 Data,格式清楚
但是不含 Preamble (8Bytes) & CRC (4Bytes)
Preamble 為 0xAA x 7, 0xAB
1.傳送端的adapter(轉接卡)會將IP datagram(IP資料封包)封裝到Ethernet frame中,並將此frame交給physical layer,接收端的adapter會從physical layer收到此frame,取出IP datagram交給network layer。
就開始了艱難的旅程
如何增進網路的速度呢? 大哉問
這是個困難的問題
因為網路速度牽扯到很多層面
光 OSI model 就有七層 Layer
AP 啦,Protocol 啦, 網路卡, 網路線, Server,甚至OS 在在都會影響傳輸的速度
一開始從 Network Driver 看起..., bla bla bla 頭暈了,
要先熟悉 NDIS架構,很熟中斷流程,看ISRHandler
看了後 也不知要從何改起
搞了很久,做了一些測試,最後靈感來了,覺得SMB要負起很大的責任
首先
上傳約100MB大小的檔案至 Linux File Server, 大約為 1.8MB/s
共54秒
再來直接連PC 傳至Windows XP, 變得更慢,耗時62~64秒
Why?
Google 了一下 SMB,它是個 Chatty (很囉嗦的) protocol
http://en.wikipedia.org/wiki/Server_Message_Block#cite_note-6
Performance issues
client make request 之後 都要等 server 給予 response而且Max Block Size 只有64KB
也就是說 最少每64KB就要communicate 一次
這個overhead 不可謂不高,尤其是在High Latency Network中
所以MS 在Vista後推出來 SMB 2.0
可惜的是 WINCE 5大概無緣享受
所以要加快速度 就是要 reduce overhead, increase block size
看看上面,為什麼直接連線至PC 不經過 router 反而比較慢呢
使用 MS Network Monitor 後發現
那是因為 WinXP default MaxBufferSize 為4356
比Linux Server 的16644 還低
所以要加速 SMB(CIFS) Performance
要調大 block size 到極限64KB
http://blogs.msdn.com/b/openspecification/archive/2009/04/10/smb-maximum-transmit-buffer-size-and-performance-tuning.aspx
http://support.microsoft.com/kb/279282/en-us
在 SMB Server (也就是Windows PC) 端
The MaxBufferSize can be configured through the following registry setting:
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\SizeReqBuf
Data Type: REG_DWORD
Range: 1024 to 65535
Default Values (If the key is not present):
For Windows Server versions of OS (NT server, Windows 2000, Windows 2003, Windows 2008)
If Physical Memory < =512M, default is 4356.
Else default value is 16644.
For Windows client versions of OS (Windows 98, NT, 2000, XP and Vista)
Default value is 4356.
在Client (WINCE)端
目前是9100bytes
上面有錯,not SizeReqBuf 而是 SizReqBuf
更改完後要重開機或者下
net stop server
net start server
http://support.microsoft.com/kb/223140/en-us
上面有錯,not SizeReqBuf 而是 SizReqBuf
更改完後要重開機或者下
net stop server
net start server
http://support.microsoft.com/kb/223140/en-us
Network Monitor 很好用
怎麼看 current smb buffer size 呢 -- R Negotiate
SMB servers return a maximum SERVER buffer size (MaxTransmotBufferSize) in the SMB negotiation response (SMB_COM_NEGOTIATE server response).
而 client 則是在 SetupANDX
The SMB client sends a maximum CLIENT buffer size to the server in SMB Session Setup request (SMB_COM_SESSION_SETUPANDX request) telling the sever what the maximum buffer size the client can support.
SPNEGO -- Linux Server
SMB Signing
Network Monitor
http://sls.weco.net/node/10698
Network Capture 的 Data,格式清楚
但是不含 Preamble (8Bytes) & CRC (4Bytes)
Preamble 為 0xAA x 7, 0xAB
1.傳送端的adapter(轉接卡)會將IP datagram(IP資料封包)封裝到Ethernet frame中,並將此frame交給physical layer,接收端的adapter會從physical layer收到此frame,取出IP datagram交給network layer。
2011年7月1日 星期五
WINCE 7 的新特色
WINCE 7 新的特色
* Support for ARM v7
* New developer and designer tools
* New technology for creating user interfaces
* New SMP (symmetric multiprocessing) support for x86 & ARM, MIPS
* New multimedia player, with customizable UI
* New version of Internet Explorer (which is based on IE 7 with some “performance updates” from IE
* Flash 10.1 support (which requires an Adobe license by OEMs who want to include that feature)
* Silverlight for Embedded support
* Improved Connectivity to PCs, servers (NDIS 6.1 support)
* New developer and designer tools
* New technology for creating user interfaces
* New SMP (symmetric multiprocessing) support for x86 & ARM, MIPS
* New multimedia player, with customizable UI
* New version of Internet Explorer (which is based on IE 7 with some “performance updates” from IE
* Flash 10.1 support (which requires an Adobe license by OEMs who want to include that feature)
* Silverlight for Embedded support
* Improved Connectivity to PCs, servers (NDIS 6.1 support)
2011年6月30日 星期四
CodeSourcery g++
心血來潮突然想用最新的compiler 來編譯 autoboot
下載了 mips-sde-elf-gcc 之後
( MIPS 的 sde 已經結束,交由 codesourcery 繼續 )
( 有 mips-elf 及 mips-linux 2種版本)
主要是 Link system 不一樣 ( ABI ?)
簡單說
mips-elf 是針對 bare-metal system ,沒有OS 的 compiler,
link 的時候要指定 linker script ( -T scriptfile )
而 mips-linux 就是針對 linux 的啦
CodeSourcery 的 compiler 不需要 cygwin
但是跟 cygwin 相容,可以在 cygwin 下使用。
這點很重要,因為大部份的 makefile 都是給 X-nix 的
裝好後( 選add to PATH) 試著編譯
出現 no input file 訊息
用舊的 sde-gcc 同樣的命令則無問題
表示 codesourcery 沒設定好
因為 cygwin 下,路徑名是 Linux 式的而非 Windows Path
所以要下
export CYGPATH=cygpath ( ref. Starter Guide)
或
export CYGPATH=xxxx\bin\cygpath
這樣CS 就會呼叫 cygpath 這個utility 來調整路徑
調整好後繼續編譯,在link的時候出現
cannot find -lc
這是因為找不到 library libc.a
設定好 config file 中的 LIBPATH 指到CS目錄下的lib
然後 -lc 換成 -lgcc (因為CS下沒有 libc.a 只有 libgcc.a )
就可以了
或者 -lc 拿掉,不指定 library,也可以過...
2個重點
1. export CYGPATH=cygpath
2. c library link problem
接下來分享並紀錄一下 gcc 的一些參數
-l statically link library, -lc 就是 libc.a -lgcc 就是 libgcc.a
-L lib link directory
-EL use little endian lib
-T specify linker script
-Wa,xxxx pass xxx option to assembler, -Wa 後面加逗號就是 pass 給assembler 的參數
編譯完後的 booter.rec.elf 檔比原來大很多 (345k vs 224k)
可能是library的關係?
但是booter.rec 大小差不多。
note: 編譯中有出現一個問題
用新的 gcc ( 4.5.2 ) vs 3.4.4
在nand.c 會出現error
static NandDevice nand_devices[] =
{
{ //Toshiba TC58DVM92A1FT00
.description("Toshiba 8-bit Flash"),
.model("TC58DVM92A1FT00"),
.maker(0x98),
.device_id(0x76),
.data_width(8),
.page_size(528),
.spare_area_size(16),
.page_count(32),
.block_count(4096),
.cs_dont_care(0),
.sequential_read(1)
},
{ //Samsung K9F1216U0A-YCB0
.description("Samsung 16-bit Flash"),
.model("K9F1216U0A-YCB0"),
.maker(0xEC),
.device_id(0x56),
.data_width(16),
.page_size(528),
.spare_area_size(16),
.page_count(32),
.block_count(4096),
.cs_dont_care(1),
.sequential_read(0)
},
...
};
typedef struct
{
char* description;
char* model;
int maker;
int device_id;
int data_width;
int page_size;
int spare_area_size;
int page_count;
int block_count;
int cs_dont_care;
int sequential_read;
} NandDevice;
其中
.description("Toshiba 8-bit Flash"), 會出現錯誤
改成
.description = "Toshiba 8-bit Flash", 就 ok了
.description = {"Toshiba 8-bit Flash" }, 的話會出現 near initialization warning
全部的 .data(XXX) 改成 .data = "XXX" 就可以過了
.data(XXX) initialize 的語法好像是 gcc 以前獨有的
可以參考
http://tigcc.ticalc.org/doc/gnuexts.html
C99 的initialization 有大改,而gcc 4 應該是符合 C99 所以 old code cannot compile
下載了 mips-sde-elf-gcc 之後
( MIPS 的 sde 已經結束,交由 codesourcery 繼續 )
( 有 mips-elf 及 mips-linux 2種版本)
主要是 Link system 不一樣 ( ABI ?)
簡單說
mips-elf 是針對 bare-metal system ,沒有OS 的 compiler,
link 的時候要指定 linker script ( -T scriptfile )
而 mips-linux 就是針對 linux 的啦
CodeSourcery 的 compiler 不需要 cygwin
但是跟 cygwin 相容,可以在 cygwin 下使用。
這點很重要,因為大部份的 makefile 都是給 X-nix 的
裝好後( 選add to PATH) 試著編譯
出現 no input file 訊息
用舊的 sde-gcc 同樣的命令則無問題
表示 codesourcery 沒設定好
因為 cygwin 下,路徑名是 Linux 式的而非 Windows Path
所以要下
export CYGPATH=cygpath ( ref. Starter Guide)
或
export CYGPATH=xxxx\bin\cygpath
這樣CS 就會呼叫 cygpath 這個utility 來調整路徑
調整好後繼續編譯,在link的時候出現
cannot find -lc
這是因為找不到 library libc.a
設定好 config file 中的 LIBPATH 指到CS目錄下的lib
然後 -lc 換成 -lgcc (因為CS下沒有 libc.a 只有 libgcc.a )
就可以了
或者 -lc 拿掉,不指定 library,也可以過...
2個重點
1. export CYGPATH=cygpath
2. c library link problem
接下來分享並紀錄一下 gcc 的一些參數
-l statically link library, -lc 就是 libc.a -lgcc 就是 libgcc.a
-L lib link directory
-EL use little endian lib
-T specify linker script
-Wa,xxxx pass xxx option to assembler, -Wa 後面加逗號就是 pass 給assembler 的參數
編譯完後的 booter.rec.elf 檔比原來大很多 (345k vs 224k)
可能是library的關係?
但是booter.rec 大小差不多。
note: 編譯中有出現一個問題
用新的 gcc ( 4.5.2 ) vs 3.4.4
在nand.c 會出現error
static NandDevice nand_devices[] =
{
{ //Toshiba TC58DVM92A1FT00
.description("Toshiba 8-bit Flash"),
.model("TC58DVM92A1FT00"),
.maker(0x98),
.device_id(0x76),
.data_width(8),
.page_size(528),
.spare_area_size(16),
.page_count(32),
.block_count(4096),
.cs_dont_care(0),
.sequential_read(1)
},
{ //Samsung K9F1216U0A-YCB0
.description("Samsung 16-bit Flash"),
.model("K9F1216U0A-YCB0"),
.maker(0xEC),
.device_id(0x56),
.data_width(16),
.page_size(528),
.spare_area_size(16),
.page_count(32),
.block_count(4096),
.cs_dont_care(1),
.sequential_read(0)
},
...
};
typedef struct
{
char* description;
char* model;
int maker;
int device_id;
int data_width;
int page_size;
int spare_area_size;
int page_count;
int block_count;
int cs_dont_care;
int sequential_read;
} NandDevice;
其中
.description("Toshiba 8-bit Flash"), 會出現錯誤
改成
.description = "Toshiba 8-bit Flash", 就 ok了
.description = {"Toshiba 8-bit Flash" }, 的話會出現 near initialization warning
全部的 .data(XXX) 改成 .data = "XXX" 就可以過了
.data(XXX) initialize 的語法好像是 gcc 以前獨有的
可以參考
http://tigcc.ticalc.org/doc/gnuexts.html
C99 的initialization 有大改,而gcc 4 應該是符合 C99 所以 old code cannot compile
2011年6月21日 星期二
WINCE Battery Driver
在尋找電源相關問題時 ( 懷疑進入battery mode, not AC mode )
對 Battery Driver 有了更深的了解
http://blog.csdn.net/pk666666/archive/2010/12/17/6082762.aspx
是很好的文章
對 Battery Driver 有了更深的了解
http://blog.csdn.net/pk666666/archive/2010/12/17/6082762.aspx
是很好的文章
一.概述
Windows CE电池驱动属于分层驱动,由MDD层和PDD层组成。驱动示例代码位于%_WINCEROOT%\Public\Common\Oak\Drivers\Battdrvr。其中battdrvr.c是MDD层代码,sbattif.c是PDD层代码。MDD层代码微软已经搭好架构,一般不需要修改,我们要实现的是PDD层的代码。
在Au1200 BSP中 sbattiff.c 被 battpdd.c 取代
二.MDD层
电池驱动对外接口函数没有“BAT_”前缀,因为HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Battery\Flags注册表项设置了DEVFLAGS_NAKEDENTRIES属性,表示“Init”代替“BAT_Init”,这样修改注册表“Prefix”项的值时不需要修改驱动代码。
DEVFLAGS_NAKEDENTRIES 重要,其值為 8
在 battdrvr.reg 中
; These registry entries load the battery driver. The IClass value must match
; the BATTERY_DRIVER_CLASS definition in battery.h -- this is how the system
; knows which device is the battery driver. Note that we are using
; DEVFLAGS_NAKEDENTRIES with this driver. This tells the device manager
; to instantiate the device with the prefix named in the registry but to look
; for DLL entry points without the prefix. For example, it will look for Init
; instead of BAT_Init. This allows the prefix to be changed in the registry (if
; desired) without editing the driver code.
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Battery]
"Prefix"="BAT"
"Dll"="battdrvr.dll"
"Flags"=dword:8 ; DEVFLAGS_NAKEDENTRIES
"Order"=dword:0
"IClass"="{DD176277-CD34-4980-91EE-67DBEF3D8913}"
2011年6月16日 星期四
NDIS Performance Test
HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > WindowsNT > CurrentVersion > NetworkCards
http://msdn.microsoft.com/en-us/library/aa463155.aspx
http://msdn.microsoft.com/en-us/library/ms894400.aspx
http://msdn.microsoft.com/en-us/library/aa463155.aspx
http://msdn.microsoft.com/en-us/library/ms894400.aspx
訂閱:
文章 (Atom)