4.13.2010

一團混亂的 Windows CE update and Rn

Windows CE 的 update 真是一團混亂,又有 update, 又有 R1,R2,R3

所謂 R? 不就是update 的總和嗎?
那不就有 年度 rollup ,為什麼還要有 R2, R3 ?

如果是分開的,那麼 裝 R3 update 還需要裝 其他 update 嗎?
如果要,安裝的順序是?

真是一團混亂呀!

4.09.2010

CopyFile 還作....

CopyFile 跟我們自己寫的 CreateFile -Read - Write 方式有什麼不同?
  • CopyFile 做完 copy 動作後,還會將 destination file 的 attribute 設得跟 sourcefile 一樣。
  • CopyFile 做完 copy 動作後,還會將 destination file 的 accesstime 設得跟 sourcefile 一樣。
  • 以上兩個動作會觸發 handle change notification.
Copy 時的動作也不一樣,會先把 Destination file用 SetFilePointer( ), SetEndOfFile( ) 撐開。
再 copy data 進去。
這可能是怕 copy 到一半,空間不夠,所以先撐開。如果空間不夠的話,就會 Fail,就不用浪費時間 copy 了
還有每copy 一單位就會 call 一次callback function (因為實際上是 call CopyFileEx),但是因為callback function 是 NULL,所以沒動作。

copyfile 的 source code 在
c:\wince600\private\winceos\coreos\core\dll\apis.c

4.08.2010

OEMKitlStartup( ) 這個 function, OEM 要 implement 好,讓 Windows CE 來 call。
但是 Windows CE call 不 call ,由 IMGNOKITL 這個 flag 決定。

KITL enable 了,也連通了。OS boot 後也不一定能 break, 用 target control 控制。
要 enable kernel debugger

這一篇 說,可以下 loaddbg 來load 也可以

ERROR_SHARING_VIOLATION - 有點白說

關於 ERROR_SHARING_VIOLATIOn 這個 error.
MS 的解釋

就是說,Windows 是一個 multi-tasking 的 OS,所以有人跟你同時在 access 一個 file,而且又同時 write....(有點看圖說故事的感覺)

所以有這個error 是很正常的事。

MS提供一個 sample code:

#define MAXRETRIES 5
#define RETRYDELAY 250

HANDLE hFile = INVALID_HANDLE_VALUE
DWORD dwRetries = 0;
BOOL bSuccess = FALSE;
DWORD dwErr = 0;

do
{
hFile = CreateFile( szFile,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if ( INVALID_HANDLE_VALUE == hFile )
{
dwErr = GetLastError();

if ( ERROR_SHARING_VIOLATION == dwErr )
{
dwRetries += 1;
Sleep(RETRYDELAY);
continue;
}
else
{
// An error occurred.
break;
}
}

bSuccess = TRUE;
break;
} while ( dwRetries < MAXRETRIES );

if ( bSuccess )
{
// You succeeded in opening the file.
}
else
{
// Failure occurs. Do graceful error handling.

// Here, you must notify the user of the failure.

MessageBox( NULL,
"Tried to update data file but it was already in use",
"Update error...",
MB_OK | MB_ICONSTOP );

// You also want to put the software back in the state it was in
// on entrance of the current function, as if the user had never
// tried to do the update.

// This may also require deallocating any resources that were
// allocated because of this operation.
}


就是有這個 error 的時候,就 sleep 一下,等那個好心的程式write 結束,再 試一次。



Windows XP 還有話說,因為一堆不知名的程式在background 跑 (virus scan, source control.. speed hd.. etc)

但是 Windows CE 還有這樣的error 真是.. 見鬼了

4.07.2010

some info for java KVM

java KVM 好像變成 J2ME CLDC ,然後又 opensource 變成 phoneME。

所以要 build KVM ,好像要到 sun (現在變成 oracle 了) 的 phoneME Project

有一個人 (http://www.cs.kuleuven.be/~davy/phoneme/) 真的太好心了。

不僅把 phoneME for CE 的 build process 寫好patch。
也release 他 build 好的 for KVM for CE : http://www.cs.kuleuven.be/~davy/phoneme/?q=node/10
但是 for CE 的 OS 需要 AYGSHELL.DLL


phoneME for winCE 比較麻煩的好像是 JavaCall 部份。
JavaCall 是有關手機部份的功能。


好心人的網頁有介紹 phoneME 的兩個 edition:
  • phoneME Feature -- 就是 CLDC
  • phoneME Advanced -- 就是 CDC
偉大的0xlab 竟然已經把 phoneme port 到 Android 上...

4.02.2010

more on celog - ref


CELZONE_ALWAYSON 0x40000000
CELZONE_BOOT_TIME 0x00010000
CELZONE_CRITSECT 0x00000100
CELZONE_DEBUG 0x00800000
CELZONE_HEAP 0x00000800
CELZONE_INTERRUPT 0x00000001
CELZONE_LOADER 0x00004000
CELZONE_SYNCH 0x00000200
===============================
0x40814901

CE 6.0 Preparation KIT 說:
NOTE Improving reference naming matching
The CeLog event-tracking system can take advantage of the kernel profiler to look up thread
function names based on start addresses when capturing CreateThread events, if you explicitly
enable the kernel profiler and add profiling symbols to the run-time image by rebuilding the
image with the IMGPROFILER environment variable set. However, CeLog can only look up the
profiling symbols built into the run-time image. Symbols of applications developed based on a
Software Development Kit (SDK) are generally unavailable to the CeLog event-tracking system.

也就是說勾選 PROFILING 就可用 fixthreads 列出 thread function name.

這一篇 http://blogs.msdn.com/ce_base/archive/2006/06/14/Thread-names-and-CeLog.aspx
也說使用 PROFILE 可以列出 thread name,
但是又說有 MAP 的話,可以用 -fixthread 或 -v 加入 thread name information

kernel tracker 的應用: 這一篇 Lock Convoys and How to Recognize Them 說明用 celog file 和 kernel tracker 找出 Lock Convoys 的狀況

用 readlog 作轉換。

celog : another way - by hand

在 news groupe 還有一篇說明: http://www.relatedterms.com/thread/1874715/If%20celog.clg%20is%20opened%20in%20kernel%20tracker%20%20the%20error%20-%20Corrupt%20datain%20log%20file%20-%20occurs.

Werner 回答說:

First, when you use IMGCELOGENABLE CeLog.dll is loaded very early in the
boot process, too early to read any registry info (as registry is not ready
yet at that time).
Second I see that you have set FlushTimeout=03e8. If you tell CeLogFlush to
use a timeout of 03e8 (1sec) it might be too fast.

What I do: Do not tick IMGCELOGENABLE, IMGOSCAPTURE, IMGAUTOFLUSH but add
celog.dll, oscapture.exe and celogflush.exe manually in your project.bib
(copy what you need to to from common.bib and common.reg). Make sure you add
the items in FILES section, not MODULES. Now CeLog.dll will only be loaded
when you run CelogFlsuh.exe or OSCapture.exe.As this is much later in the
boot process (I expect that the UI is up and running by then), CeLog.dll can
access the regsitry and load your registry settings. This way you can
increase the buffer size and leave the Flush Timeout to 10sec.

Are you using Celog in a DEBUG or RETAIL build? I have problems using CeLog
in DEBUG (together with VS + PlatformBuilder 6.0). After Celog.dll loads, it
crashes my image. In a RELEASE build everything works as expected.

Werner